Skip to content

Commit

Permalink
Label override flags for dbAuth generator (#6440)
Browse files Browse the repository at this point in the history
* initial ability to pass label arguements

* Added remaining parameters to auth template files

* Added no default value check in order to pass tests

* Apply suggestions: reduce templateVars duplication

Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>

* Apply suggestions: replace ternary

Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>

* Added missing templateVars declaration

* Renamed template vars

* Renamed flags to include 'label', added prompts and used listr2 tasks for user interrogation

* Updated yarn.lock

* Added default values within  function

* Updated web authn page template - not tested

* Moved WebAuthn into listr

* Some tidying up

* Fix default webauthn flag value check

* Added enquirer option and other minor fixes

* Added tests for prompts

* Add web.app to the mocked getPaths

* Fix password label and add listr2 options to task handler

* Added snapshot tests

* Added --username-label and --password-label flags to the docs for rw g dbAuth

* Normalise paths within tests

* Added test for custom labels and webauthn enabled

* Add flags to prevent test project creation prompting the user

* Updated test project fixtures

* update snapshots and set mockfiles before test describe

* Customised auth variables similar to labels

* updated test fixtures

* Update test snapshots

* Updated to use customised variable names based on label option

* Add missing dbAuth command test

Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: Rob Cameron <cannikin@fastmail.com>
  • Loading branch information
3 people committed Dec 12, 2022
1 parent df1b410 commit 21b6b51
Show file tree
Hide file tree
Showing 14 changed files with 5,430 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ const ForgotPasswordPage = () => {
errorClassName="rw-input rw-input-error"
ref={usernameRef}
validation={{
required: true,
required: {
value: true,
message: 'Username is required',
},
}}
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const ResetPasswordPage = ({ resetToken }: { resetToken: string }) => {
validation={{
required: {
value: true,
message: 'Password is required',
message: 'New Password is required',
},
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const SignupPage = () => {
}
}, [isAuthenticated])

// focus on email box on page load
// focus on username box on page load
const usernameRef = useRef<HTMLInputElement>(null)
useEffect(() => {
usernameRef.current?.focus()
Expand Down
10 changes: 6 additions & 4 deletions docs/docs/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,12 @@ Generate log in, sign up, forgot password and password reset pages for dbAuth
yarn redwood generate dbAuth
```
| Arguments & Options | Description |
| ------------------- | ------------------------------------------------------------------------------------------------ |
| `--webAuthn` | Whether or not to add webAuthn support to the log in page. If not specified you will be prompted |
| `--rollback` | Rollback changes if an error occurs [default: true] |
| Arguments & Options | Description |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `--username-label` | The label to give the username field on the auth forms, e.g. "Email". Defaults to "Username". If not specified you will be prompted |
| `--password-label` | The label to give the password field on the auth forms, e.g. "Secret". Defaults to "Password". If not specified you will be prompted |
| `--webAuthn` | Whether or not to add webAuthn support to the log in page. If not specified you will be prompted |
| `--rollback` | Rollback changes if an error occurs [default: true]
If you don't want to create your own log in, sign up, forgot password and
password reset pages from scratch you can use this generator. The pages will be
Expand Down

0 comments on commit 21b6b51

Please sign in to comment.