Skip to content

Commit

Permalink
Add docs for how to trigger a policy (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
byn9826 authored Nov 7, 2024
1 parent d663ab5 commit 2cffc89
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
- OTP MFA
- SMS MFA
- MFA Enrollment
- <b>Policy</b>
- sign_in_or_sign_up
- change_password
- <b>Mailer Option</b>:
- SendGrid
- Mailgun
Expand Down
25 changes: 25 additions & 0 deletions docs/q&a.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,28 @@ After running these commands, the old secret will be removed, and any tokens sig
- Enforcing specific MFA types: You can set OTP_MFA_IS_REQUIRED, SMS_MFA_IS_REQUIRED, or EMAIL_MFA_IS_REQUIRED to true to enforce those MFA methods as a login requirement.
- Letting users choose one of the supported MFA types: If OTP_MFA_IS_REQUIRED, SMS_MFA_IS_REQUIRED, and EMAIL_MFA_IS_REQUIRED are all set to false, you can set ENFORCE_ONE_MFA_ENROLLMENT to contain the MFA types you want to support. The user will then be required to enroll in one of the selected MFA types.
- You can also use the MFA enrollment functionality provided by the admin panel or the S2S API to customize your MFA enrollment flow.

## How to trigger a different policy
- To trigger a different policy, add policy=[policy] as a query string when redirecting the user to the authorization page.
```
const url = serverUri +
'/oauth2/v1/authorize?' +
'response_type=code' +
'&state=' + state +
'&client_id=' + clientId +
'&redirect_uri=' + redirectUri +
'&code_challenge=' + codeChallenge +
'&code_challenge_method=S256' +
'&policy=' + policy +
'&scope=' + scope +
'&locale=' + locale
window.location.href = url
```
- When using the React SDK, you can trigger the loginRedirect function with a policy parameter:
```
const { loginRedirect } = useAuth()
loginRedirect({
policy: 'change_password',
})
```
1 change: 1 addition & 0 deletions docs/react-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Triggers a new authentication flow.
|-----------|------|-------------|---------|----------|
| locale | string | Specifies the locale to use in the authentication flow | N/A | No |
| state | string | Specifies the state to use in the authentication flow if you prefer not to use a randomly generated string | N/A | No |
| policy | string | Specifies the policy to use in the authentication flow | 'sign_in_or_sign_up' | No |

```
import { useAuth } from '@melody-auth/react'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "melody-auth",
"version": "1.0.8",
"version": "1.1.0",
"description": "A turnkey OAuth & authentication system.",
"license": "MIT",
"author": "Baozier",
Expand Down

0 comments on commit 2cffc89

Please sign in to comment.