# Ultimail — inscription self-service (email, mot de passe, profil, avatar optionnel)
version: 1
metadata:
  name: Ultimail enrollment
  labels:
    blueprints.goauthentik.io/instantiate: "true"
entries:
  - model: authentik_flows.flow
    id: ulti-enrollment-flow
    identifiers:
      slug: ulti-enrollment
    attrs:
      name: Ultimail — Créer un compte
      title: Créer votre compte Ultimail
      designation: enrollment
      authentication: require_unauthenticated

  - model: authentik_stages_prompt.prompt
    id: ulti-enroll-field-email
    identifiers:
      name: ulti-enrollment-field-email
    attrs:
      field_key: username
      label: Adresse e-mail
      type: email
      required: true
      placeholder: vous@exemple.com
      placeholder_expression: false
      order: 0

  - model: authentik_stages_prompt.prompt
    id: ulti-enroll-field-email-sync
    identifiers:
      name: ulti-enrollment-field-email-sync
    attrs:
      field_key: email
      label: E-mail
      type: hidden
      required: true
      initial_value: "{{ prompt_data.username }}"
      initial_value_expression: true
      placeholder_expression: false
      order: 1

  - model: authentik_stages_prompt.prompt
    id: ulti-enroll-field-password
    identifiers:
      name: ulti-enrollment-field-password
    attrs:
      field_key: password
      label: Mot de passe
      type: password
      required: true
      placeholder: Mot de passe
      placeholder_expression: false
      order: 1

  - model: authentik_stages_prompt.prompt
    id: ulti-enroll-field-password-repeat
    identifiers:
      name: ulti-enrollment-field-password-repeat
    attrs:
      field_key: password_repeat
      label: Confirmer le mot de passe
      type: password
      required: true
      placeholder: Confirmer le mot de passe
      placeholder_expression: false
      order: 2

  - model: authentik_stages_prompt.prompt
    id: ulti-enroll-field-name
    identifiers:
      name: ulti-enrollment-field-name
    attrs:
      field_key: name
      label: Nom et prénom
      type: text
      required: true
      placeholder: Jean Dupont
      placeholder_expression: false
      order: 0

  - model: authentik_stages_prompt.prompt
    id: ulti-enroll-field-phone
    identifiers:
      name: ulti-enrollment-field-phone
    attrs:
      field_key: attributes.phone
      label: Numéro de téléphone (optionnel)
      type: text
      required: false
      placeholder: +33 6 12 34 56 78
      placeholder_expression: false
      order: 1

  - model: authentik_stages_prompt.prompt
    id: ulti-enroll-field-avatar
    identifiers:
      name: ulti-enrollment-field-avatar
    attrs:
      field_key: attributes.avatar
      label: Photo de profil (optionnel)
      type: file
      required: false
      placeholder: ""
      placeholder_expression: false
      order: 2

  - model: authentik_stages_prompt.promptstage
    id: ulti-enroll-prompt-credentials
    identifiers:
      name: ulti-enrollment-prompt-credentials
    attrs:
      fields:
        - !KeyOf ulti-enroll-field-email
        - !KeyOf ulti-enroll-field-email-sync
        - !KeyOf ulti-enroll-field-password
        - !KeyOf ulti-enroll-field-password-repeat

  - model: authentik_stages_prompt.promptstage
    id: ulti-enroll-prompt-profile
    identifiers:
      name: ulti-enrollment-prompt-profile
    attrs:
      fields:
        - !KeyOf ulti-enroll-field-name
        - !KeyOf ulti-enroll-field-phone
        - !KeyOf ulti-enroll-field-avatar

  - model: authentik_stages_user_write.userwritestage
    id: ulti-enroll-user-write
    identifiers:
      name: ulti-enrollment-user-write
    attrs:
      user_creation_mode: always_create
      create_users_as_inactive: false

  - model: authentik_stages_user_login.userloginstage
    id: ulti-enroll-user-login
    identifiers:
      name: ulti-enrollment-user-login

  - model: authentik_flows.flowstagebinding
    identifiers:
      target: !KeyOf ulti-enrollment-flow
      stage: !KeyOf ulti-enroll-prompt-credentials
      order: 10

  - model: authentik_flows.flowstagebinding
    identifiers:
      target: !KeyOf ulti-enrollment-flow
      stage: !KeyOf ulti-enroll-prompt-profile
      order: 20

  - model: authentik_flows.flowstagebinding
    identifiers:
      target: !KeyOf ulti-enrollment-flow
      stage: !KeyOf ulti-enroll-user-write
      order: 30

  - model: authentik_flows.flowstagebinding
    identifiers:
      target: !KeyOf ulti-enrollment-flow
      stage: !KeyOf ulti-enroll-user-login
      order: 100
