mirror of https://git.48k.eu/ogcp
Add user role administrator
ogCP now have to types of users, regular and administrator users. ogCP configuration file defines users roles with the boolean field "ADMIN".multi-ogserver
parent
c7b0024d24
commit
57da4f4efa
|
@ -7,11 +7,13 @@
|
|||
{
|
||||
"USER": "admin",
|
||||
"PASS": "5b722b307fce6c944905d132691d5e4a2214b7fe92b738920eb3fce3a90420a19511c3010a0e7712b054daef5b57bad59ecbd93b3280f210578f547f4aed4d25",
|
||||
"ADMIN": true,
|
||||
"SCOPES": [ ]
|
||||
},
|
||||
{
|
||||
"USER": "user",
|
||||
"PASS": "5b722b307fce6c944905d132691d5e4a2214b7fe92b738920eb3fce3a90420a19511c3010a0e7712b054daef5b57bad59ecbd93b3280f210578f547f4aed4d25",
|
||||
"ADMIN": false,
|
||||
"SCOPES": [
|
||||
"Unidad Organizativa (Default)"
|
||||
]
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
from flask_login import UserMixin
|
||||
|
||||
class User(UserMixin):
|
||||
def __init__(self, username, scopes):
|
||||
def __init__(self, username, scopes, admin):
|
||||
self.id = username
|
||||
self.scopes = scopes
|
||||
self.admin = admin
|
||||
|
|
|
@ -210,7 +210,7 @@ def load_user(username):
|
|||
if not user_dict:
|
||||
return None
|
||||
|
||||
user = User(username, user_dict.get('SCOPES'))
|
||||
user = User(username, user_dict.get('SCOPES'), user_dict.get('ADMIN'))
|
||||
return user
|
||||
|
||||
@app.before_request
|
||||
|
@ -265,7 +265,7 @@ def login():
|
|||
user_dict = authenticate_user(form_user, pwd)
|
||||
if not user_dict:
|
||||
return render_template('auth/login.html', form=form)
|
||||
user = User(form_user, user_dict.get('SCOPES'))
|
||||
user = User(form_user, user_dict.get('SCOPES'), user_dict.get('ADMIN'))
|
||||
login_user(user)
|
||||
return redirect(url_for('index'))
|
||||
return render_template('auth/login.html', form=LoginForm())
|
||||
|
|
Loading…
Reference in New Issue