Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use messages instead of errors #48

Merged
merged 1 commit into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"homepage": "https://github.com/ory/kratos-selfservice-ui-node#readme",
"dependencies": {
"@oryd/kratos-client": "0.0.0-next.e568324ce78b",
"@oryd/kratos-client": "0.0.0-next.2609b90cf011",
"@types/cookie-parser": "^1.4.2",
"@types/express": "^4.17.2",
"@types/express-handlebars": "0.0.33",
Expand Down
6 changes: 5 additions & 1 deletion src/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ export const authHandler = (type: 'login' | 'registration') => (
}
}

res.render(type, {oidc:methodConfig("oidc"), password:methodConfig("password")})
res.render(type, {
...request,
oidc:methodConfig("oidc"),
password:methodConfig("password"),
})
})
.catch(err => {
console.error(err)
Expand Down
1 change: 1 addition & 0 deletions src/routes/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const settingsHandler = (req: Request, res: Response, next: NextFunction) => {

if (request) {
res.render('settings', {
...request,
password: methodConfig("password"),
profile: methodConfig("profile"),
oidc: methodConfig("oidc"),
Expand Down
4 changes: 3 additions & 1 deletion src/routes/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export default (req: Request, res: Response, next: NextFunction) => {
return body
}
).then((request: any) => {
res.render('verification', request.form)
res.render('verification', {
...request
})
}
).catch((err: any) => next(err))
}
2 changes: 2 additions & 0 deletions views/login.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{{> icon_logo}}
<h5 class="subheading">Welcome to this example login screen!</h5>

{{> messages messages=messages className="global"}}

{{#if password}}
<div id="login-password">
{{> form submitLabel="Sign in" form=password}}
Expand Down
2 changes: 1 addition & 1 deletion views/partials/form.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{> form_errors className="overview-form-errors" errors=form.errors}}
<form action="{{form.action}}" method="{{form.method}}">
{{> messages messages=form.messages }}
{{> form_fields fields=form.fields }}
{{#if submitLabel}}
<button type="submit">{{submitLabel}}</button>
Expand Down
5 changes: 0 additions & 5 deletions views/partials/form_errors.hbs

This file was deleted.

2 changes: 1 addition & 1 deletion views/partials/form_input_default.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<input name="{{name}}" type="{{type}}" value="{{value}}" placeholder="{{getTitle name}}" {{#if disabled}}disabled{{/if}}>
<span>{{getTitle name}}</span>
</label>
{{> form_errors className="input-form-errors"}}
{{> messages }}
</fieldset>
2 changes: 1 addition & 1 deletion views/partials/form_input_password.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<span>{{getTitle name}}</span>
{{> form_input_password_toggle }}
</label>
{{> form_errors className="input-form-errors"}}
{{> messages }}
</fieldset>
5 changes: 0 additions & 5 deletions views/partials/form_messages.hbs

This file was deleted.

5 changes: 5 additions & 0 deletions views/partials/messages.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="messages {{className}}">
{{~#each messages~}}
<div class="message {{type}}">{{text}}</div>
{{~/each~}}
</div>
2 changes: 1 addition & 1 deletion views/recovery.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="container">
<h4>Recover your account</h4>

{{> form_messages messages=messages className="global"}}
{{> messages messages=messages className="global"}}

{{#if token}}
<div id="recovery-token">
Expand Down
2 changes: 2 additions & 0 deletions views/registration.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<h5 class="subheading">Welcome to SecureApp! <br/>
Use the form below to sign up:</h5>

{{> messages messages=messages className="global"}}

{{#if password}}
<div id="registration-password">
{{> form submitLabel="Sign up" form=password}}
Expand Down
2 changes: 2 additions & 0 deletions views/settings.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<div class="container">
<h2>Settings</h2>

{{> messages messages=messages className="global"}}

{{#if updateSuccessful}}
<p>Your changes have been saved!</p>
{{/if}}
Expand Down
6 changes: 3 additions & 3 deletions views/verification.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div class="container">
<h4>Resend verification code</h4>

{{> form_errors errors=errors className="overview-form-errors"}}
{{> messages messages=messages className="global"}}

<form action="{{action}}" method="{{method}}">
{{#each fields}}
<form action="{{form.action}}" method="{{form.method}}">
{{#each form.fields}}
{{> (toFormInputPartialName type)}}
{{/each}}
<button type="submit">Resend verification code</button>
Expand Down