first commit

This commit is contained in:
2018-08-01 16:00:05 +02:00
commit 944fd76206
3205 changed files with 356767 additions and 0 deletions
@@ -0,0 +1,6 @@
{% extends 'partials/base.html.twig' %}
{% block content %}
{% include 'partials/messages.html.twig' %}
{% include 'partials/forgot-form.html.twig' %}
{% endblock %}
@@ -0,0 +1,28 @@
{% extends "forms/field.html.twig" %}
{% block input %}
<div class="form-input-wrapper twofa-wrapper">
{% try %}
{% set user = grav.user %}
{% set secret = user.twofa_secret ?: grav.login.twoFactorAuth.createSecret() %}
{% set image = grav.login.twoFactorAuth.getQrImageData(user.username, secret) %}
<img style="border: 1px solid #ddd" data-2fa-image src="{{ image }}" />
<div>
<span>{{ 'PLUGIN_LOGIN.2FA_SECRET'|tu }}: </span><span class="twofa-secret-code" data-2fa-secret>{{ secret|regex_replace('/(\\w{4})/', '\\1 ') }}</span>
</div>
{% if admin %}
<div class="danger twofa-wrapper">
<button data-hint="{{ 'PLUGIN_LOGIN.2FA_REGEN_HINT'|tu }}" class="button button-small hint--bottom" data-2fa-regenerate><i class="fa fa-fw fa-refresh"></i> {{ 'PLUGIN_LOGIN.2FA_REGENERATE'|t }}</button>
</div>
{% endif %}
<input type="text" class="no-form" style="display:none;" name="{{ (scope ~ field.name)|fieldName }}" data-2fa-value value="{{ secret }}" />
{% catch %}
<div class="notice error">
<p>{{ e.message }}</p>
</div>
{% endcatch %}
</div>
{% endblock %}
@@ -0,0 +1,6 @@
{% extends 'partials/base.html.twig' %}
{% block content %}
{% include 'partials/messages.html.twig' %}
{% include 'partials/login-form.html.twig' %}
{% endblock %}
@@ -0,0 +1,5 @@
{%- if not grav.user.authenticated -%}
{"code":401,"status":"unauthenticated","error":{"message":"Authentication required","login":{{ include('partials/login-form.html.twig')|trim|json_encode }}}}
{%- else -%}
{"code":200,"status":"authenticated","message":"You have been authenticated"}
{%- endif -%}
@@ -0,0 +1,18 @@
<section id="grav-login">
{{ content|raw }}
<form method="post" action="{{ (base_url_relative ~ uri.path)|e }}">
{% for field in form.fields %}
{% if field.type %}
<div>
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
</div>
{% endif %}
{% endfor %}
<div class="form-actions secondary-accent">
<button type="submit" class="button primary" name="task" value="login.forgot"><i class="fa fa-paper-plane"></i> {{ "PLUGIN_LOGIN.BTN_SEND_INSTRUCTIONS"|t }}</button>
</div>
{{ nonce_field('forgot-form', 'forgot-form-nonce')|raw }}
</form>
</section>
+61
View File
@@ -0,0 +1,61 @@
<section id="grav-login">
{% if page.template == 'login' or show_login_form %}
{% set user = grav.user %}
{% if user.authenticated and user.authorized %}
<h4>{{ 'PLUGIN_LOGIN.WELCOME'|t }} <strong>{{ user.fullname ?: user.username }}</strong></h4>
<hr>
<a class="button logout" href="{{ uri.addNonce(base_url_relative ~ uri.path ~ '/task' ~ config.system.param_sep ~ 'login.logout', 'logout-form', 'logout-nonce')|e }}">{{ 'PLUGIN_LOGIN.BTN_LOGOUT'|t }}</a>
{% elseif user.authenticated and user.twofa_enabled %}
{% include 'partials/login-twofa.html.twig' %}
{% else %}
{{ content|raw }}
{# NEW WAY OF INCLUDING 3RD PARTY LOGIN OPTIONS #}
{% for template in grav.login.getProviderLoginTemplates %}
{% include template %}
{% endfor %}
<form method="post" action="{{ (base_url_relative ~ uri.path)|e }}" class="{{ form_outer_classes }}">
{# OLD WAY OF INCLUDING 3RD PARTY LOGIN OPTIONS #}
{% if grav.twig.plugins_hooked_loginPage %}
{% for label in grav.twig.plugins_hooked_loginPage %}
{% include label %}
{% endfor %}
{% endif %}
{% for field in form.fields %}
{% set value = field.name == 'username' ? username : '' %}
{% if field.type %}
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
{% endif %}
{% endfor %}
<div class="{{ form_button_outer_classes ?: 'form-actions secondary-accent' }}">
{% if config.plugins.login.rememberme.enabled and page.header.form.login.rememberme ?? true %}
<div class="form-data rememberme" data-grav-default="null" data-grav-disabled="true" data-grav-field="checkbox">
<div class="form-input-wrapper">
<input type="checkbox" value="1" name="rememberme" id="#rememberme">
<label class="inline" for="#rememberme" title="{{ 'PLUGIN_LOGIN.REMEMBER_ME_HELP'|t }}">{{ 'PLUGIN_LOGIN.REMEMBER_ME'|t }}</label>
</div>
</div>
{% endif %}
{% if page.header.form.login.forgot_button ?? true %}
<a class="{{ form_button_classes ?: 'button secondary' }}" href="{{ base_url_relative }}{{ config.plugins.login.route_forgot }}"><i class="fa fa-exclamation-circle"></i> {{ 'PLUGIN_LOGIN.BTN_FORGOT'|t }}</a>
{% endif %}
<button class="{{ form_button_classes ?: 'button primary' }}" type="submit" name="task" value="login.login"><i class="fa fa-sign-in"></i> {{ 'PLUGIN_LOGIN.BTN_LOGIN'|t }}</button>
</div>
{{ nonce_field('login-form', 'login-form-nonce')|raw }}
</form>
{% endif %}
{% endif %}
</section>
@@ -0,0 +1,5 @@
<span class="login-status">
{% if grav.user.authenticated %}
<strong>{{ grav.user.fullname ?: grav.user.username }}</strong>, <a class="logout" href="{{ uri.addNonce((base_url_relative ~ uri.path)|trim('/') ~ '/task' ~ config.system.param_sep ~ 'login.logout', 'logout-form', 'logout-nonce')|e }}">{{ 'PLUGIN_LOGIN.BTN_LOGOUT'|t }}</a>
{% endif %}
</span>
@@ -0,0 +1,20 @@
{% set form = forms('login-twofa') %}
<form method="post" action="{{ (base_url_relative ~ uri.path)|e }}" class="{{ form_outer_classes }}">
{% for field in form.fields %}
{% if field.type %}
<div>
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
</div>
{% endif %}
{% endfor %}
{{ nonce_field('login-form', 'login-form-nonce')|raw }}
<div class="{{ form_button_outer_classes ?: 'form-actions secondary-accent' }}">
<div class="form-actions primary-accent">
<button type="submit" class="button" name="task" value="login.logout">{{ 'PLUGIN_LOGIN.BTN_CANCEL'|t }}</button>
<button type="submit" class="button primary" name="task" value="login.twofa">{{ 'PLUGIN_LOGIN.BTN_LOGIN'|t }}</button>
</div>
</div>
</form>
@@ -0,0 +1,24 @@
{% if uri.param('token') and uri.param('task') %}
<section id="grav-login">
{{ content|raw }}
<form method="post" action="{{ (base_url_relative ~ uri.path)|e }}" classes="{{ form_outer_classes }}">
{% for field in form.fields %}
{% set value = attribute(grav.twig.twig_vars, field.name) is defined ? attribute(grav.twig.twig_vars, field.name) : null %}
{% if field.type %}
<div>
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
</div>
{% endif %}
{% endfor %}
<div class="form-actions secondary-accent">
<button type="submit" class="button primary" name="task" value="login.reset"><i class="fa fa-key"></i> {{ "PLUGIN_LOGIN.BTN_RESET"|t }}</button>
</div>
{{ nonce_field('reset-form', 'reset-form-nonce')|raw }}
</form>
</section>
{% endif %}
@@ -0,0 +1,9 @@
{% extends 'partials/base.html.twig' %}
{% do form.setAllData(grav.user.toArray) %}
{% block content %}
{% include 'partials/messages.html.twig' %}
{{ page.content }}
{% include 'forms/form.html.twig' %}
{% endblock %}
@@ -0,0 +1 @@
{% extends 'forms/ajax.json.twig' %}
@@ -0,0 +1,8 @@
{% extends 'partials/base.html.twig' %}
{% block content %}
{% include 'partials/messages.html.twig' %}
{% include 'partials/reset-form.html.twig' %}
{% endblock %}