2024-04-24 11:20:17 -07:00
|
|
|
import base64
|
|
|
|
|
import json
|
2024-03-19 09:30:20 -07:00
|
|
|
import uuid
|
2024-03-19 11:32:36 -07:00
|
|
|
from datetime import datetime, timedelta
|
2016-01-19 15:50:31 +00:00
|
|
|
|
2024-03-19 11:32:36 -07:00
|
|
|
from flask import (
|
|
|
|
|
abort,
|
|
|
|
|
current_app,
|
2024-04-25 13:48:14 -07:00
|
|
|
flash,
|
2024-03-19 11:32:36 -07:00
|
|
|
redirect,
|
|
|
|
|
render_template,
|
|
|
|
|
request,
|
|
|
|
|
session,
|
|
|
|
|
url_for,
|
|
|
|
|
)
|
2016-10-13 17:05:37 +01:00
|
|
|
from flask_login import current_user
|
2016-01-22 17:24:14 +00:00
|
|
|
|
2024-03-19 11:32:36 -07:00
|
|
|
from app import user_api_client
|
2015-12-01 13:23:54 +00:00
|
|
|
from app.main import main
|
2016-03-02 15:25:04 +00:00
|
|
|
from app.main.forms import (
|
|
|
|
|
RegisterUserForm,
|
2018-02-19 16:53:29 +00:00
|
|
|
RegisterUserFromInviteForm,
|
2018-02-20 11:22:17 +00:00
|
|
|
RegisterUserFromOrgInviteForm,
|
2024-03-19 09:30:20 -07:00
|
|
|
SetupUserProfileForm,
|
2016-03-02 15:25:04 +00:00
|
|
|
)
|
2024-03-19 11:32:36 -07:00
|
|
|
from app.main.views import sign_in
|
2017-11-10 12:35:21 +00:00
|
|
|
from app.main.views.verify import activate_user
|
Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
API (returns JSON)
⬇
API client (returns a built in type, usually `dict`)
⬇
Model (returns an instance, eg of type `Service`)
⬇
View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:
```
API (returns JSON)
⬇
API client (returns a model, of type `User`, `InvitedUser`, etc)
⬇
View (returns HTML)
```
This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.
It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.
For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-05-23 15:27:35 +01:00
|
|
|
from app.models.user import InvitedOrgUser, InvitedUser, User
|
2024-04-24 11:20:17 -07:00
|
|
|
from app.utils import hide_from_search_engines, hilite
|
2015-12-01 13:23:54 +00:00
|
|
|
|
2016-01-11 15:17:00 +00:00
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/register", methods=["GET", "POST"])
|
2020-05-26 17:39:25 +01:00
|
|
|
@hide_from_search_engines
|
2016-01-08 15:12:14 +00:00
|
|
|
def register():
|
2016-05-04 13:01:55 +01:00
|
|
|
if current_user and current_user.is_authenticated:
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(url_for("main.show_accounts_or_dashboard"))
|
2016-01-22 17:24:14 +00:00
|
|
|
|
2016-01-28 16:36:36 +00:00
|
|
|
form = RegisterUserForm()
|
2015-12-01 13:23:54 +00:00
|
|
|
if form.validate_on_submit():
|
2016-07-12 11:53:30 +01:00
|
|
|
_do_registration(form, send_sms=False)
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(url_for("main.registration_continue"))
|
2016-03-09 15:12:33 +00:00
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
return render_template("views/register.html", form=form)
|
2016-03-02 15:25:04 +00:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/register-from-invite", methods=["GET", "POST"])
|
2024-05-06 12:15:57 -07:00
|
|
|
# TODO This is deprecated, we are now handling invites in the
|
|
|
|
|
# login.gov workflow
|
2016-03-02 15:25:04 +00:00
|
|
|
def register_from_invite():
|
Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
API (returns JSON)
⬇
API client (returns a built in type, usually `dict`)
⬇
Model (returns an instance, eg of type `Service`)
⬇
View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:
```
API (returns JSON)
⬇
API client (returns a model, of type `User`, `InvitedUser`, etc)
⬇
View (returns HTML)
```
This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.
It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.
For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-05-23 15:27:35 +01:00
|
|
|
invited_user = InvitedUser.from_session()
|
2016-03-02 15:25:04 +00:00
|
|
|
if not invited_user:
|
|
|
|
|
abort(404)
|
|
|
|
|
|
2017-11-14 15:53:38 +00:00
|
|
|
form = RegisterUserFromInviteForm(invited_user)
|
2017-11-14 15:03:05 +00:00
|
|
|
|
2016-03-02 15:25:04 +00:00
|
|
|
if form.validate_on_submit():
|
2023-08-25 09:12:23 -07:00
|
|
|
if (
|
|
|
|
|
form.service.data != invited_user.service
|
|
|
|
|
or form.email_address.data != invited_user.email_address
|
|
|
|
|
):
|
2016-03-02 15:25:04 +00:00
|
|
|
abort(400)
|
Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
API (returns JSON)
⬇
API client (returns a built in type, usually `dict`)
⬇
Model (returns an instance, eg of type `Service`)
⬇
View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:
```
API (returns JSON)
⬇
API client (returns a model, of type `User`, `InvitedUser`, etc)
⬇
View (returns HTML)
```
This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.
It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.
For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-05-23 15:27:35 +01:00
|
|
|
_do_registration(form, send_email=False, send_sms=invited_user.sms_auth)
|
|
|
|
|
invited_user.accept_invite()
|
|
|
|
|
if invited_user.sms_auth:
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(url_for("main.verify"))
|
2017-11-10 12:35:21 +00:00
|
|
|
else:
|
|
|
|
|
# we've already proven this user has email because they clicked the invite link,
|
|
|
|
|
# so just activate them straight away
|
2023-08-25 09:12:23 -07:00
|
|
|
return activate_user(session["user_details"]["id"])
|
2016-03-02 15:25:04 +00:00
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
return render_template(
|
|
|
|
|
"views/register-from-invite.html", invited_user=invited_user, form=form
|
|
|
|
|
)
|
2016-03-02 15:25:04 +00:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/register-from-org-invite", methods=["GET", "POST"])
|
2024-05-06 12:15:57 -07:00
|
|
|
# TODO This is deprecated, we are now handling invites in the
|
|
|
|
|
# login.gov workflow
|
2018-02-19 16:53:29 +00:00
|
|
|
def register_from_org_invite():
|
Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
API (returns JSON)
⬇
API client (returns a built in type, usually `dict`)
⬇
Model (returns an instance, eg of type `Service`)
⬇
View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:
```
API (returns JSON)
⬇
API client (returns a model, of type `User`, `InvitedUser`, etc)
⬇
View (returns HTML)
```
This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.
It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.
For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-05-23 15:27:35 +01:00
|
|
|
invited_org_user = InvitedOrgUser.from_session()
|
2018-02-19 16:53:29 +00:00
|
|
|
if not invited_org_user:
|
|
|
|
|
abort(404)
|
|
|
|
|
|
|
|
|
|
form = RegisterUserFromOrgInviteForm(
|
|
|
|
|
invited_org_user,
|
|
|
|
|
)
|
2023-08-25 09:12:23 -07:00
|
|
|
form.auth_type.data = "sms_auth"
|
2018-02-19 16:53:29 +00:00
|
|
|
|
|
|
|
|
if form.validate_on_submit():
|
2023-08-25 09:12:23 -07:00
|
|
|
if (
|
|
|
|
|
form.organization.data != invited_org_user.organization
|
|
|
|
|
or form.email_address.data != invited_org_user.email_address
|
|
|
|
|
):
|
2018-02-19 16:53:29 +00:00
|
|
|
abort(400)
|
2023-08-25 09:12:23 -07:00
|
|
|
_do_registration(
|
|
|
|
|
form,
|
|
|
|
|
send_email=False,
|
|
|
|
|
send_sms=True,
|
|
|
|
|
organization_id=invited_org_user.organization,
|
|
|
|
|
)
|
Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
API (returns JSON)
⬇
API client (returns a built in type, usually `dict`)
⬇
Model (returns an instance, eg of type `Service`)
⬇
View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:
```
API (returns JSON)
⬇
API client (returns a model, of type `User`, `InvitedUser`, etc)
⬇
View (returns HTML)
```
This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.
It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.
For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-05-23 15:27:35 +01:00
|
|
|
invited_org_user.accept_invite()
|
2018-02-19 16:53:29 +00:00
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(url_for("main.verify"))
|
|
|
|
|
return render_template(
|
|
|
|
|
"views/register-from-org-invite.html",
|
|
|
|
|
invited_org_user=invited_org_user,
|
|
|
|
|
form=form,
|
|
|
|
|
)
|
2018-02-19 16:53:29 +00:00
|
|
|
|
|
|
|
|
|
2023-07-12 12:09:44 -04:00
|
|
|
def _do_registration(form, send_sms=True, send_email=True, organization_id=None):
|
Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
API (returns JSON)
⬇
API client (returns a built in type, usually `dict`)
⬇
Model (returns an instance, eg of type `Service`)
⬇
View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:
```
API (returns JSON)
⬇
API client (returns a model, of type `User`, `InvitedUser`, etc)
⬇
View (returns HTML)
```
This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.
It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.
For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-05-23 15:27:35 +01:00
|
|
|
user = User.from_email_address_or_none(form.email_address.data)
|
|
|
|
|
if user:
|
2018-02-19 16:53:29 +00:00
|
|
|
if send_email:
|
Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
API (returns JSON)
⬇
API client (returns a built in type, usually `dict`)
⬇
Model (returns an instance, eg of type `Service`)
⬇
View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:
```
API (returns JSON)
⬇
API client (returns a model, of type `User`, `InvitedUser`, etc)
⬇
View (returns HTML)
```
This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.
It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.
For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-05-23 15:27:35 +01:00
|
|
|
user.send_already_registered_email()
|
2023-08-25 09:12:23 -07:00
|
|
|
session["expiry_date"] = str(datetime.utcnow() + timedelta(hours=1))
|
|
|
|
|
session["user_details"] = {"email": user.email_address, "id": user.id}
|
2018-02-19 16:53:29 +00:00
|
|
|
else:
|
Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
API (returns JSON)
⬇
API client (returns a built in type, usually `dict`)
⬇
Model (returns an instance, eg of type `Service`)
⬇
View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:
```
API (returns JSON)
⬇
API client (returns a model, of type `User`, `InvitedUser`, etc)
⬇
View (returns HTML)
```
This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.
It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.
For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-05-23 15:27:35 +01:00
|
|
|
user = User.register(
|
|
|
|
|
name=form.name.data,
|
|
|
|
|
email_address=form.email_address.data,
|
|
|
|
|
mobile_number=form.mobile_number.data,
|
|
|
|
|
password=form.password.data,
|
|
|
|
|
auth_type=form.auth_type.data,
|
|
|
|
|
)
|
|
|
|
|
|
2016-03-15 16:58:26 +00:00
|
|
|
if send_email:
|
Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
API (returns JSON)
⬇
API client (returns a built in type, usually `dict`)
⬇
Model (returns an instance, eg of type `Service`)
⬇
View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:
```
API (returns JSON)
⬇
API client (returns a model, of type `User`, `InvitedUser`, etc)
⬇
View (returns HTML)
```
This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.
It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.
For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-05-23 15:27:35 +01:00
|
|
|
user.send_verify_email()
|
2016-03-17 13:07:52 +00:00
|
|
|
|
|
|
|
|
if send_sms:
|
Make user API client return JSON, not a model
The data flow of other bits of our application looks like this:
```
API (returns JSON)
⬇
API client (returns a built in type, usually `dict`)
⬇
Model (returns an instance, eg of type `Service`)
⬇
View (returns HTML)
```
The user API client was architected weirdly, in that it returned a model
directly, like this:
```
API (returns JSON)
⬇
API client (returns a model, of type `User`, `InvitedUser`, etc)
⬇
View (returns HTML)
```
This mixing of different layers of the application is bad because it
makes it hard to write model code that doesn’t have circular
dependencies. As our application gets more complicated we will be
relying more on models to manage this complexity, so we should make it
easy, not hard to write them.
It also means that most of our mocking was of the User model, not just
the underlying JSON. So it would have been easy to introduce subtle bugs
to the user model, because it wasn’t being comprehensively tested. A lot
of the changed lines of code in this commit mean changing the tests to
mock only the JSON, which means that the model layer gets implicitly
tested.
For those reasons this commit changes the user API client to return
JSON, not an instance of `User` or other models.
2019-05-23 15:27:35 +01:00
|
|
|
user.send_verify_code()
|
2023-08-25 09:12:23 -07:00
|
|
|
session["expiry_date"] = str(datetime.utcnow() + timedelta(hours=1))
|
|
|
|
|
session["user_details"] = {"email": user.email_address, "id": user.id}
|
2023-07-12 12:09:44 -04:00
|
|
|
if organization_id:
|
2023-08-25 09:12:23 -07:00
|
|
|
session["organization_id"] = organization_id
|
2016-03-17 13:07:52 +00:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/registration-continue")
|
2016-03-17 13:07:52 +00:00
|
|
|
def registration_continue():
|
2023-08-25 09:12:23 -07:00
|
|
|
if not session.get("user_details"):
|
|
|
|
|
return redirect(url_for(".show_accounts_or_dashboard"))
|
2024-03-19 09:30:20 -07:00
|
|
|
else:
|
|
|
|
|
raise Exception("Unexpected routing in registration_continue")
|
|
|
|
|
|
2024-03-18 13:50:23 -04:00
|
|
|
|
2024-03-19 11:32:36 -07:00
|
|
|
@main.route("/set-up-your-profile", methods=["GET", "POST"])
|
2024-03-18 13:50:23 -04:00
|
|
|
@hide_from_search_engines
|
|
|
|
|
def set_up_your_profile():
|
2024-03-19 09:30:20 -07:00
|
|
|
|
|
|
|
|
form = SetupUserProfileForm()
|
|
|
|
|
|
2024-03-19 13:30:50 -07:00
|
|
|
if form.validate_on_submit():
|
2024-03-19 09:30:20 -07:00
|
|
|
# start login.gov
|
|
|
|
|
code = request.args.get("code")
|
|
|
|
|
state = request.args.get("state")
|
|
|
|
|
login_gov_error = request.args.get("error")
|
|
|
|
|
if code and state:
|
2024-05-06 13:12:27 -07:00
|
|
|
_handle_login_dot_gov_invite(code, state, form)
|
2024-03-19 09:30:20 -07:00
|
|
|
elif login_gov_error:
|
|
|
|
|
current_app.logger.error(f"login.gov error: {login_gov_error}")
|
|
|
|
|
raise Exception(f"Could not login with login.gov {login_gov_error}")
|
|
|
|
|
# end login.gov
|
|
|
|
|
|
2024-03-18 13:50:23 -04:00
|
|
|
return render_template("views/set-up-your-profile.html", form=form)
|
2024-05-06 12:15:57 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_invited_user_email_address(invited_user_id):
|
|
|
|
|
# InvitedUser is an unhashable type and hard to mock in tests
|
|
|
|
|
# so this convenience method is a workaround for that
|
|
|
|
|
invited_user = InvitedUser.by_id(invited_user_id)
|
|
|
|
|
return invited_user.email_address
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def invited_user_accept_invite(invited_user_id):
|
|
|
|
|
# InvitedUser is an unhashable type and hard to mock in tests
|
|
|
|
|
# so this convenience method is a workaround for that
|
|
|
|
|
invited_user = InvitedUser.by_id(invited_user_id)
|
|
|
|
|
invited_user.accept_invite()
|
|
|
|
|
|
|
|
|
|
|
2024-05-06 13:12:27 -07:00
|
|
|
def _handle_login_dot_gov_invite(code, state, form):
|
2024-05-06 12:15:57 -07:00
|
|
|
|
|
|
|
|
access_token = sign_in._get_access_token(code, state)
|
|
|
|
|
user_email, user_uuid = sign_in._get_user_email_and_uuid(access_token)
|
|
|
|
|
invite_data = state.encode("utf8")
|
|
|
|
|
invite_data = base64.b64decode(invite_data)
|
|
|
|
|
invite_data = json.loads(invite_data)
|
|
|
|
|
invited_user_id = invite_data["invited_user_id"]
|
|
|
|
|
invited_user_email_address = get_invited_user_email_address(invited_user_id)
|
|
|
|
|
if user_email.lower() != invited_user_email_address.lower():
|
|
|
|
|
flash("You cannot accept an invite for another person.")
|
|
|
|
|
session.pop("invited_user_id", None)
|
|
|
|
|
abort(403)
|
|
|
|
|
else:
|
|
|
|
|
invited_user_accept_invite()
|
|
|
|
|
current_app.logger.debug(
|
|
|
|
|
hilite(
|
|
|
|
|
f"INVITED USER {invited_user_email_address} to service {invite_data['service_id']}"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
current_app.logger.debug(hilite("ACCEPTED INVITE"))
|
2024-05-06 13:12:27 -07:00
|
|
|
user = user_api_client.get_user_by_uuid_or_email(user_uuid, user_email)
|
|
|
|
|
if user is None:
|
|
|
|
|
user = User.register(
|
|
|
|
|
name=form.name.data,
|
|
|
|
|
email_address=user_email,
|
|
|
|
|
mobile_number=form.mobile_number.data,
|
|
|
|
|
password=str(uuid.uuid4()),
|
|
|
|
|
auth_type="sms_auth",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# activate the user
|
|
|
|
|
user = user_api_client.get_user_by_uuid_or_email(user_uuid, user_email)
|
|
|
|
|
activate_user(user["id"])
|
|
|
|
|
usr = User.from_id(user["id"])
|
|
|
|
|
usr.add_to_service(
|
|
|
|
|
invite_data["service_id"],
|
|
|
|
|
invite_data["permissions"],
|
|
|
|
|
invite_data["folder_permissions"],
|
|
|
|
|
invite_data["from_user_id"],
|
|
|
|
|
)
|
|
|
|
|
current_app.logger.debug(
|
|
|
|
|
hilite(
|
|
|
|
|
f"Added user {usr.email_address} to service {invite_data['service_id']}"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
return redirect(url_for("main.show_accounts_or_dashboard"))
|