zitadel/internal/user/repository/view/user_session_by_id.sql
Tim Möhlmann b6841251b1
feat(users/v2): return prompt information (#9255)
# Which Problems Are Solved

Add the ability to update the timestamp when MFA initialization was last
skipped.
Get User By ID now also returns the timestamps when MFA setup was last
skipped.

# How the Problems Are Solved

- Add a `HumanMFAInitSkipped` method to the `users/v2` API.
- MFA skipped was already projected in the `auth.users3` table. In this
PR the same column is added to the users projection. Event handling is
kept the same as in the `UserView`:

<details>


62804ca45f/internal/user/repository/view/model/user.go (L243-L377)

</details>

# Additional Changes

- none

# Additional Context

- Closes https://github.com/zitadel/zitadel/issues/9197
2025-01-29 15:12:31 +00:00

30 lines
1006 B
SQL

SELECT s.creation_date,
s.change_date,
s.resource_owner,
s.state,
s.user_agent_id,
s.user_id,
u.username,
l.login_name,
h.display_name,
h.avatar_key,
s.selected_idp_config_id,
s.password_verification,
s.passwordless_verification,
s.external_login_verification,
s.second_factor_verification,
s.second_factor_verification_type,
s.multi_factor_verification,
s.multi_factor_verification_type,
s.sequence,
s.instance_id,
s.id
FROM auth.user_sessions s
LEFT JOIN projections.users14 u ON s.user_id = u.id AND s.instance_id = u.instance_id
LEFT JOIN projections.users14_humans h ON s.user_id = h.user_id AND s.instance_id = h.instance_id
LEFT JOIN projections.login_names3 l ON s.user_id = l.user_id AND s.instance_id = l.instance_id AND l.is_primary = true
WHERE (s.user_agent_id = $1)
AND (s.user_id = $2)
AND (s.instance_id = $3)
LIMIT 1
;