-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add endpoint for retrieving the user detail based on token
- Loading branch information
Showing
13 changed files
with
127 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import json | ||
import requests | ||
from flask import Blueprint, render_template, request, redirect, url_for, session | ||
from wtforms import Form, StringField, PasswordField, validators | ||
|
||
from authserver.db import db, User, OAuth2Client | ||
|
||
home_bp = Blueprint('home_ep', __name__, static_folder='static', template_folder='templates', url_prefix='/') | ||
|
||
|
||
class LoginForm(Form): | ||
username = StringField('Username', [validators.DataRequired(), validators.length(min=4, max=40)]) | ||
password = PasswordField('Password', [validators.DataRequired()]) | ||
|
||
|
||
@home_bp.route('/', methods=['GET', 'POST']) | ||
def login(): | ||
form = LoginForm(request.form) | ||
client_id = request.args.get('client_id') | ||
return_to = request.args.get('return_to') | ||
if request.method == 'GET': | ||
if not client_id or not return_to: | ||
return render_template('login.html', form=form) | ||
else: | ||
return render_template('login.html', client_id=client_id, return_to=return_to, form=form) | ||
if form.validate(): | ||
username = form.username.data | ||
password = form.password.data | ||
user = User.query.filter_by(username=username).first() | ||
if user and user.verify_password(password): | ||
session['id'] = user.id | ||
return redirect(return_to) | ||
else: | ||
if not client_id or not return_to: | ||
return redirect(url_for('home_ep.login')) | ||
else: | ||
return redirect(url_for('home_ep.login', client_id=client_id, return_to=return_to)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
body { | ||
background-color:#333333; | ||
font-family: 'Raleway', sans-serif; | ||
} | ||
|
||
label { | ||
color: #ffffff; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{% macro render_field(field) %} | ||
<div class="form-row"> | ||
<div class="row"> | ||
<div class="col"> | ||
<label for="{{ field.name }}">{{ field.label }}</label> | ||
</div> | ||
<div class="col"> | ||
{{ field(**kwargs)|safe }} | ||
</div> | ||
</div> | ||
</div> | ||
{% if field.errors %} | ||
<ul class=errors> | ||
{% for error in field.errors %} | ||
<li>{{ error }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
</dd> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters