Module m_auth2fa

Generate TOTP image data: urls.

Copyright © 2019-2021 Marc Worrell

Behaviours: zotonic_model.

Authors: Marc Worrell (marc@worrell.nl).

Description

Generate TOTP image data: urls.

Function Index

is_totp_enabled/2Check if totp is enabled for the given user.
is_valid_totp/3Check if the given code is a valid TOTP code.
m_get/3
mode/1Check the totp mode.
request_key/1
set_request_key/1
totp_disable/2Remove the totp tokens and disable totp for the user.
totp_image_url/2Generate a new totp code and return the barcode / QR code.
user_mode/1Check the totp mode for the current user: 0 = optional, 1 = ask, 2 = required.

Function Details

is_totp_enabled/2

is_totp_enabled(UserId::m_rsc:resource_id(), Context::z:context()) -> boolean()

Check if totp is enabled for the given user

is_valid_totp/3

is_valid_totp(UserId::m_rsc:resource_id(), Code::binary(), Context::z:context()) -> boolean()

Check if the given code is a valid TOTP code

m_get/3

m_get(Rest, Msg, Context) -> any()

mode/1

mode(Context::z:context()) -> 0 | 1 | 2

Check the totp mode

request_key/1

request_key(Context::z:context()) -> binary() | undefined

set_request_key/1

set_request_key(Context::z:context()) -> binary() | undefined

totp_disable/2

totp_disable(UserId::m_rsc:resource_id(), Context::z:context()) -> ok

Remove the totp tokens and disable totp for the user

totp_image_url/2

totp_image_url(UserId::m_rsc:resource_id(), Context::z:context()) -> {ok, {Url::binary(), Secret::binary()}} | {error, eacces}

Generate a new totp code and return the barcode / QR code

user_mode/1

user_mode(Context::z:context()) -> 0 | 1 | 2

Check the totp mode for the current user: 0 = optional, 1 = ask, 2 = required


Generated by EDoc