Manage Account membership on oidc login

This commit is contained in:
Nick Douma
2020-03-06 16:01:18 +01:00
parent 7ef6f5db4e
commit 27f5c89f70
5 changed files with 54 additions and 6 deletions

View File

@ -94,6 +94,8 @@ class Setting(db.Model):
'oidc_oauth_firstname': 'given_name',
'oidc_oauth_last_name': 'family_name ',
'oidc_oauth_email': 'email',
'oidc_oauth_account_name_property': '',
'oidc_oauth_account_description_property': '',
'forward_records_allow_edit': {
'A': True,
'AAAA': True,

View File

@ -589,3 +589,21 @@ class User(db.Model):
return {'status': True, 'msg': 'Set user role successfully'}
else:
return {'status': False, 'msg': 'Role does not exist'}
def get_accounts(self):
"""
Get accounts associated with this user
"""
from .account import Account
from .account_user import AccountUser
accounts = []
query = db.session\
.query(
AccountUser,
Account)\
.filter(User.id == AccountUser.user_id)\
.filter(Account.id == AccountUser.account_id)\
.all()
for q in query:
accounts.append(q[1])
return accounts