2022-08-05 22:52:12 +00:00
|
|
|
version: 1
|
2022-08-02 22:05:49 +00:00
|
|
|
metadata:
|
|
|
|
name: Default - User settings flow
|
2022-07-31 15:11:44 +00:00
|
|
|
entries:
|
|
|
|
- attrs:
|
|
|
|
designation: stage_configuration
|
2022-08-01 21:05:58 +00:00
|
|
|
name: User settings
|
|
|
|
title: Update your info
|
2022-12-02 15:14:25 +00:00
|
|
|
authentication: require_authenticated
|
2022-07-31 15:11:44 +00:00
|
|
|
identifiers:
|
|
|
|
slug: default-user-settings-flow
|
|
|
|
model: authentik_flows.flow
|
|
|
|
id: flow
|
|
|
|
- attrs:
|
|
|
|
order: 200
|
|
|
|
placeholder: |
|
|
|
|
try:
|
|
|
|
return user.username
|
|
|
|
except:
|
|
|
|
return ''
|
|
|
|
placeholder_expression: true
|
|
|
|
required: true
|
|
|
|
type: text
|
|
|
|
field_key: username
|
|
|
|
label: Username
|
2023-01-24 11:23:22 +00:00
|
|
|
identifiers:
|
|
|
|
name: default-user-settings-field-username
|
2022-07-31 15:11:44 +00:00
|
|
|
id: prompt-field-username
|
|
|
|
model: authentik_stages_prompt.prompt
|
|
|
|
- attrs:
|
|
|
|
order: 201
|
|
|
|
placeholder: |
|
|
|
|
try:
|
|
|
|
return user.name
|
|
|
|
except:
|
|
|
|
return ''
|
|
|
|
placeholder_expression: true
|
|
|
|
required: true
|
|
|
|
type: text
|
|
|
|
field_key: name
|
|
|
|
label: Name
|
2023-01-24 11:23:22 +00:00
|
|
|
identifiers:
|
|
|
|
name: default-user-settings-field-name
|
2022-07-31 15:11:44 +00:00
|
|
|
id: prompt-field-name
|
|
|
|
model: authentik_stages_prompt.prompt
|
|
|
|
- attrs:
|
|
|
|
order: 202
|
|
|
|
placeholder: |
|
|
|
|
try:
|
|
|
|
return user.email
|
|
|
|
except:
|
|
|
|
return ''
|
|
|
|
placeholder_expression: true
|
|
|
|
required: true
|
|
|
|
type: email
|
|
|
|
field_key: email
|
|
|
|
label: Email
|
2023-01-24 11:23:22 +00:00
|
|
|
identifiers:
|
|
|
|
name: default-user-settings-field-email
|
2022-07-31 15:11:44 +00:00
|
|
|
id: prompt-field-email
|
|
|
|
model: authentik_stages_prompt.prompt
|
|
|
|
- attrs:
|
|
|
|
order: 203
|
|
|
|
placeholder: |
|
|
|
|
try:
|
|
|
|
return user.attributes.get("settings", {}).get("locale", "")
|
|
|
|
except:
|
|
|
|
return ''
|
|
|
|
placeholder_expression: true
|
|
|
|
required: true
|
|
|
|
type: ak-locale
|
|
|
|
field_key: attributes.settings.locale
|
|
|
|
label: Locale
|
2023-01-24 11:23:22 +00:00
|
|
|
identifiers:
|
|
|
|
name: default-user-settings-field-locale
|
2022-07-31 15:11:44 +00:00
|
|
|
id: prompt-field-locale
|
|
|
|
model: authentik_stages_prompt.prompt
|
|
|
|
- attrs:
|
|
|
|
expression: |
|
|
|
|
from authentik.lib.config import CONFIG
|
|
|
|
from authentik.core.models import (
|
|
|
|
USER_ATTRIBUTE_CHANGE_EMAIL,
|
|
|
|
USER_ATTRIBUTE_CHANGE_NAME,
|
|
|
|
USER_ATTRIBUTE_CHANGE_USERNAME
|
|
|
|
)
|
|
|
|
prompt_data = request.context.get("prompt_data")
|
|
|
|
|
|
|
|
if not request.user.group_attributes(request.http_request).get(
|
|
|
|
USER_ATTRIBUTE_CHANGE_EMAIL, CONFIG.y_bool("default_user_change_email", True)
|
|
|
|
):
|
|
|
|
if prompt_data.get("email") != request.user.email:
|
|
|
|
ak_message("Not allowed to change email address.")
|
|
|
|
return False
|
|
|
|
|
|
|
|
if not request.user.group_attributes(request.http_request).get(
|
|
|
|
USER_ATTRIBUTE_CHANGE_NAME, CONFIG.y_bool("default_user_change_name", True)
|
|
|
|
):
|
|
|
|
if prompt_data.get("name") != request.user.name:
|
|
|
|
ak_message("Not allowed to change name.")
|
|
|
|
return False
|
|
|
|
|
|
|
|
if not request.user.group_attributes(request.http_request).get(
|
|
|
|
USER_ATTRIBUTE_CHANGE_USERNAME, CONFIG.y_bool("default_user_change_username", True)
|
|
|
|
):
|
|
|
|
if prompt_data.get("username") != request.user.username:
|
|
|
|
ak_message("Not allowed to change username.")
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
identifiers:
|
|
|
|
name: default-user-settings-authorization
|
2022-08-01 21:05:58 +00:00
|
|
|
id: default-user-settings-authorization
|
2022-07-31 15:11:44 +00:00
|
|
|
model: authentik_policies_expression.expressionpolicy
|
2022-08-05 22:52:12 +00:00
|
|
|
- identifiers:
|
2022-07-31 15:11:44 +00:00
|
|
|
name: default-user-settings-write
|
2022-12-23 13:12:58 +00:00
|
|
|
attrs:
|
2023-01-05 14:46:20 +00:00
|
|
|
user_creation_mode: never_create
|
2022-07-31 15:11:44 +00:00
|
|
|
id: default-user-settings-write
|
|
|
|
model: authentik_stages_user_write.userwritestage
|
|
|
|
- attrs:
|
|
|
|
fields:
|
|
|
|
- !KeyOf prompt-field-username
|
|
|
|
- !KeyOf prompt-field-name
|
|
|
|
- !KeyOf prompt-field-email
|
|
|
|
- !KeyOf prompt-field-locale
|
|
|
|
validation_policies:
|
|
|
|
- !KeyOf default-user-settings-authorization
|
|
|
|
identifiers:
|
|
|
|
name: default-user-settings
|
|
|
|
id: default-user-settings
|
|
|
|
model: authentik_stages_prompt.promptstage
|
2022-08-05 22:52:12 +00:00
|
|
|
- identifiers:
|
2022-07-31 15:11:44 +00:00
|
|
|
order: 20
|
|
|
|
stage: !KeyOf default-user-settings
|
|
|
|
target: !KeyOf flow
|
|
|
|
model: authentik_flows.flowstagebinding
|
2022-08-05 22:52:12 +00:00
|
|
|
- identifiers:
|
2022-07-31 15:11:44 +00:00
|
|
|
order: 100
|
|
|
|
stage: !KeyOf default-user-settings-write
|
|
|
|
target: !KeyOf flow
|
|
|
|
model: authentik_flows.flowstagebinding
|