-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] handle validation errors in mellow vue (#82)
* feat(mellow-vue): update badRequest response * feat(mellow-vue): update inertia-sails and install sails-flash * chore(mellow-vue): turn of typechecking js files * feat(mellow-vue): update login action and page to display validation errors * feat(mellow-vue): modify signup action to handle validation errors * feat(mellow-vue): display validation errors
- Loading branch information
1 parent
022be64
commit fff1304
Showing
8 changed files
with
123 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ password attempt.`, | |
email: { | ||
description: 'The email to try in this attempt, e.g. "[email protected]".', | ||
type: 'string', | ||
isEmail: true, | ||
required: true | ||
}, | ||
|
||
|
@@ -39,6 +40,9 @@ that, thanks to the included "custom" hook, when a relevant request is received | |
from a logged-in user, that user's entire record from the database will be fetched | ||
and exposed as a shared data via loggedInUser prop.)`, | ||
responseType: 'redirect' | ||
}, | ||
badCombo: { | ||
responseType: 'badRequest' | ||
} | ||
}, | ||
|
||
|
@@ -48,12 +52,23 @@ and exposed as a shared data via loggedInUser prop.)`, | |
}) | ||
|
||
if (!user) { | ||
throw 'badCombo' | ||
throw { | ||
badCombo: { | ||
problems: [{ login: 'Wrong email/password.' }] | ||
} | ||
} | ||
} | ||
|
||
await sails.helpers.passwords | ||
.checkPassword(password, user.password) | ||
.intercept('incorrect', 'badCombo') | ||
try { | ||
await sails.helpers.passwords.checkPassword(password, user.password) | ||
} catch (e) { | ||
sails.log.error(e.message) | ||
throw { | ||
badCombo: { | ||
problems: [{ login: 'Wrong email/password.' }] | ||
} | ||
} | ||
} | ||
|
||
if (rememberMe) { | ||
this.req.session.cookie.maxAge = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters