Api changes (#128)
* feat(api): include smtp flag in login response * feat(api): changed smtp flag in login response * feat(api): owner role is not allowed to change * feat(api): changed chalice template * feat(api): reset password invitation|token * feat(api): fixed invitation token * feat(api): after invitation return identical result
This commit is contained in:
parent
b91d51486c
commit
52908e2311
3 changed files with 42 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
|
||||
from chalicelib.core import authorizers
|
||||
from chalicelib.core import authorizers, metadata, projects
|
||||
|
||||
from chalicelib.utils import helper
|
||||
from chalicelib.utils import pg_client
|
||||
|
|
@ -430,8 +430,26 @@ def set_password_invitation(user_id, new_password):
|
|||
"invitationToken": None, "invitedAt": None,
|
||||
"changePwdExpireAt": None, "changePwdToken": None}
|
||||
user = update(tenant_id=-1, user_id=user_id, changes=changes)
|
||||
return {"data": user,
|
||||
"jwt": authenticate(user["email"], new_password)["jwt"]}
|
||||
r = authenticate(user['email'], user['password'])
|
||||
tenant_id = r.pop("tenantId")
|
||||
|
||||
r["limits"] = {
|
||||
"teamMember": -1,
|
||||
"projects": -1,
|
||||
"metadata": metadata.get_remaining_metadata_with_count(tenant_id)}
|
||||
|
||||
c = tenants.get_by_tenant_id(tenant_id)
|
||||
c.pop("createdAt")
|
||||
c["projects"] = projects.get_projects(tenant_id=tenant_id, recording_state=True, recorded=True,
|
||||
stack_integrations=True)
|
||||
c["smtp"] = helper.has_smtp()
|
||||
return {
|
||||
'jwt': r.pop('jwt'),
|
||||
'data': {
|
||||
"user": r,
|
||||
"client": c
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def count_members():
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ def process_invitation_link():
|
|||
'Content-Type': 'text/plain'})
|
||||
|
||||
|
||||
@app.route('/users/invitation/password', methods=['POST', 'PUT'], authorizer=None)
|
||||
@app.route('/password/reset', methods=['POST', 'PUT'], authorizer=None)
|
||||
def change_password_by_invitation():
|
||||
data = app.current_request.json_body
|
||||
if data is None or len(data.get("invitation", "")) < 64 or len(data.get("pass", "")) < 8:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
|
||||
from chalicelib.core import authorizers
|
||||
from chalicelib.core import authorizers, metadata, projects
|
||||
from chalicelib.core import tenants
|
||||
from chalicelib.utils import helper
|
||||
from chalicelib.utils import pg_client
|
||||
|
|
@ -440,8 +440,25 @@ def set_password_invitation(user_id, new_password):
|
|||
"invitationToken": None, "invitedAt": None,
|
||||
"changePwdExpireAt": None, "changePwdToken": None}
|
||||
user = update(tenant_id=-1, user_id=user_id, changes=changes)
|
||||
return {"data": user,
|
||||
"jwt": authenticate(user["email"], new_password)["jwt"]}
|
||||
r = authenticate(user['email'], user['password'])
|
||||
|
||||
tenant_id = r.pop("tenantId")
|
||||
r["limits"] = {
|
||||
"teamMember": -1,
|
||||
"projects": -1,
|
||||
"metadata": metadata.get_remaining_metadata_with_count(tenant_id)}
|
||||
|
||||
c = tenants.get_by_tenant_id(tenant_id)
|
||||
c.pop("createdAt")
|
||||
c["projects"] = projects.get_projects(tenant_id=tenant_id, recording_state=True, recorded=True,
|
||||
stack_integrations=True)
|
||||
return {
|
||||
'jwt': r.pop('jwt'),
|
||||
'data': {
|
||||
"user": r,
|
||||
"client": c,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def count_members(tenant_id):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue