Merge branch 'master' into oauth_redirect
# Conflicts: # realms/modules/auth/views.py
This commit is contained in:
commit
2ce6c2d314
41 changed files with 350 additions and 213 deletions
|
@ -1,6 +1,6 @@
|
|||
from realms import login_manager
|
||||
from flask import request, flash, redirect
|
||||
from flask.ext.login import login_url
|
||||
from flask_login import login_url
|
||||
|
||||
modules = set()
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from flask import render_template
|
||||
from flask.ext.login import login_user
|
||||
from flask_login import login_user
|
||||
from realms import ldap
|
||||
from flask_ldap_login import LDAPLoginForm
|
||||
from ..models import BaseUser
|
||||
|
|
|
@ -2,10 +2,10 @@ import click
|
|||
from realms.lib.util import random_string
|
||||
from realms.modules.auth.local.models import User
|
||||
from realms.lib.util import green, red, yellow
|
||||
from realms import flask_cli
|
||||
from realms import cli_group
|
||||
|
||||
|
||||
@flask_cli.group(short_help="Auth Module")
|
||||
@cli_group(short_help="Auth Module")
|
||||
def cli():
|
||||
pass
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from flask import current_app, render_template
|
||||
from flask.ext.login import logout_user, login_user
|
||||
from flask_login import logout_user, login_user
|
||||
from realms import login_manager, db
|
||||
from realms.lib.model import Model
|
||||
from ..models import BaseUser
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from flask import current_app
|
||||
from flask.ext.login import UserMixin, logout_user, AnonymousUserMixin
|
||||
from flask_login import UserMixin, logout_user, AnonymousUserMixin
|
||||
from realms import login_manager
|
||||
from realms.lib.util import gravatar_url
|
||||
from itsdangerous import URLSafeSerializer, BadSignature
|
||||
|
|
|
@ -40,7 +40,7 @@ providers = {
|
|||
'field_map': {
|
||||
'id': 'id',
|
||||
'username': 'login',
|
||||
'email': 'email'
|
||||
'email': lambda(data): data.get('email') or data['login'] + '@users.noreply.github.com'
|
||||
},
|
||||
'token_name': 'access_token'
|
||||
},
|
||||
|
@ -118,6 +118,8 @@ class User(BaseUser):
|
|||
def get_value(d, key):
|
||||
if isinstance(key, basestring):
|
||||
return d.get(key)
|
||||
elif callable(key):
|
||||
return key(d)
|
||||
# key should be list here
|
||||
val = d.get(key.pop(0))
|
||||
if len(key) == 0:
|
||||
|
|
29
realms/modules/auth/templates/auth/ldap/login.html
Normal file
29
realms/modules/auth/templates/auth/ldap/login.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
{% from 'macros.html' import render_form, render_field %}
|
||||
{% if config.get('AUTH_LOCAL_ENABLE') %}
|
||||
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#ldap-modal">
|
||||
<i class="fa fa-folder-open-o"></i> Login with LDAP
|
||||
</button>
|
||||
|
||||
<div class="modal fade" id="ldap-modal" tabindex="-1" role="dialog" aria-labelledby="ldap-login">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="ldap-login">LDAP Login</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{% call render_form(form, action_url=url_for('auth.ldap.login'), action_text='Login', btn_class='btn btn-primary') %}
|
||||
{{ render_field(form.username, placeholder='Username', type='text', required=1) }}
|
||||
{{ render_field(form.password, placeholder='Password', type='password', required=1) }}
|
||||
{% endcall %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<h3><i class="fa fa-folder-open-o"></i> LDAP Login</h3>
|
||||
{% call render_form(form, action_url=url_for('auth.ldap.login'), action_text='Login', btn_class='btn btn-primary') %}
|
||||
{{ render_field(form.username, placeholder='Username', type='text', required=1) }}
|
||||
{{ render_field(form.password, placeholder='Password', type='password', required=1) }}
|
||||
{% endcall %}
|
||||
{% endif %}
|
5
realms/modules/auth/templates/auth/local/login.html
Normal file
5
realms/modules/auth/templates/auth/local/login.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% from 'macros.html' import render_form, render_field %}
|
||||
{% call render_form(form, action_url=url_for('auth.local.login'), action_text='Login', btn_class='btn btn-primary') %}
|
||||
{{ render_field(form.email, placeholder='Email', type='email', required=1) }}
|
||||
{{ render_field(form.password, placeholder='Password', type='password', required=1) }}
|
||||
{% endcall %}
|
4
realms/modules/auth/templates/auth/login.html
Normal file
4
realms/modules/auth/templates/auth/login.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% block body %}
|
||||
{{ forms|safe }}
|
||||
{% endblock %}
|
13
realms/modules/auth/templates/auth/register.html
Normal file
13
realms/modules/auth/templates/auth/register.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% from 'macros.html' import render_form, render_field %}
|
||||
{% block body %}
|
||||
{% call render_form(form, action_url=url_for('auth.local.register'), action_text='Register', btn_class='btn btn-primary') %}
|
||||
{{ render_field(form.username, placeholder='Username', type='username', **{"required": 1, "data-parsley-type": "alphanum"}) }}
|
||||
{{ render_field(form.email, placeholder='Email', type='email', required=1) }}
|
||||
{{ render_field(form.password, placeholder='Password', type='password', **{"required": 1, "data-parsley-minlength": "6"}) }}
|
||||
{{ render_field(form.confirm, placeholder='Confirm Password', type='password', **{"required": 1, "data-parsley-minlength": "6"}) }}
|
||||
{% if config.RECAPTCHA_ENABLE %}
|
||||
{{ render_field(form.recaptcha) }}
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endblock %}
|
5
realms/modules/auth/templates/auth/settings.html
Normal file
5
realms/modules/auth/templates/auth/settings.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% from 'macros.html' import render_form, render_field %}
|
||||
{% block body %}
|
||||
|
||||
{% endblock %}
|
|
@ -1,8 +1,8 @@
|
|||
from flask import current_app, render_template, request, redirect, Blueprint, flash, url_for, session
|
||||
from flask.ext.login import logout_user
|
||||
from flask_login import logout_user
|
||||
from realms.modules.auth.models import Auth
|
||||
|
||||
blueprint = Blueprint('auth', __name__)
|
||||
blueprint = Blueprint('auth', __name__, template_folder='templates')
|
||||
|
||||
|
||||
@blueprint.route("/login", methods=['GET', 'POST'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue