mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
Merge pull request #5107 from overleaf/jk-de-ng-reconfirm-and-pw-reset
[web] de-ng password reset and must-reconfirm forms GitOrigin-RevId: 2101493ff017ba56214c6f981129f94eb9db46aa
This commit is contained in:
parent
53698fb980
commit
0ae8f37629
4 changed files with 35 additions and 28 deletions
|
@ -63,7 +63,7 @@ module.exports = {
|
||||||
requestReset(req, res, next) {
|
requestReset(req, res, next) {
|
||||||
const email = EmailsHelper.parseEmail(req.body.email)
|
const email = EmailsHelper.parseEmail(req.body.email)
|
||||||
if (!email) {
|
if (!email) {
|
||||||
return res.status(400).send({
|
return res.status(400).json({
|
||||||
message: req.i18n.translate('must_be_email_address'),
|
message: req.i18n.translate('must_be_email_address'),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -74,15 +74,15 @@ module.exports = {
|
||||||
})
|
})
|
||||||
next(err)
|
next(err)
|
||||||
} else if (status === 'primary') {
|
} else if (status === 'primary') {
|
||||||
res.status(200).send({
|
res.status(200).json({
|
||||||
message: { text: req.i18n.translate('password_reset_email_sent') },
|
message: req.i18n.translate('password_reset_email_sent'),
|
||||||
})
|
})
|
||||||
} else if (status === 'secondary') {
|
} else if (status === 'secondary') {
|
||||||
res.status(404).send({
|
res.status(404).json({
|
||||||
message: req.i18n.translate('secondary_email_password_reset'),
|
message: req.i18n.translate('secondary_email_password_reset'),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
res.status(404).send({
|
res.status(404).json({
|
||||||
message: req.i18n.translate('cant_find_email'),
|
message: req.i18n.translate('cant_find_email'),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
extends ../layout
|
extends ../layout-marketing
|
||||||
include ../_mixins/recaptcha
|
include ../_mixins/recaptcha
|
||||||
|
|
||||||
block vars
|
block vars
|
||||||
|
@ -26,37 +26,37 @@ block content
|
||||||
h1 #{translate("password_reset")}
|
h1 #{translate("password_reset")}
|
||||||
.messageArea
|
.messageArea
|
||||||
form(
|
form(
|
||||||
async-form="password-reset-request",
|
data-ol-form
|
||||||
name="passwordResetForm"
|
name="passwordResetForm"
|
||||||
action="/user/password/reset",
|
action="/user/password/reset",
|
||||||
method="POST",
|
method="POST",
|
||||||
captcha=(showCaptcha ? '' : false),
|
captcha=(showCaptcha ? '' : false),
|
||||||
captcha-action-name=(showCaptcha ? "passwordReset" : false),
|
captcha-action-name=(showCaptcha ? "passwordReset" : false),
|
||||||
ng-cloak
|
|
||||||
)
|
)
|
||||||
|
div(data-ol-form-messages)
|
||||||
|
|
||||||
input(type="hidden", name="_csrf", value=csrfToken)
|
input(type="hidden", name="_csrf", value=csrfToken)
|
||||||
form-messages(for="passwordResetForm" role="alert")
|
|
||||||
.form-group
|
.form-group
|
||||||
label(for='email') #{translate("please_enter_email")}
|
label(for='email') #{translate("please_enter_email")}
|
||||||
input.form-control#email(
|
input.form-control#email(
|
||||||
|
aria-label="email"
|
||||||
type='email',
|
type='email',
|
||||||
name='email',
|
name='email',
|
||||||
placeholder='email@example.com',
|
placeholder='email@example.com',
|
||||||
required,
|
required,
|
||||||
autocomplete="username",
|
autocomplete="username",
|
||||||
ng-model="email",
|
|
||||||
autofocus
|
autofocus
|
||||||
)
|
)
|
||||||
span.small.text-primary(
|
|
||||||
ng-show="passwordResetForm.email.$invalid && passwordResetForm.email.$dirty"
|
|
||||||
) #{translate("must_be_email_address")}
|
|
||||||
.actions
|
.actions
|
||||||
button.btn.btn-primary(
|
button.btn.btn-primary(
|
||||||
type='submit',
|
type='submit',
|
||||||
ng-disabled="passwordResetForm.$invalid || passwordResetForm.inflight"
|
data-ol-disabled-inflight,
|
||||||
|
aria-label=translate('request_password_reset_to_reconfirm')
|
||||||
)
|
)
|
||||||
span(ng-hide="passwordResetForm.inflight") #{translate("request_password_reset")}
|
span(data-ol-not-inflight-text)
|
||||||
span(ng-show="passwordResetForm.inflight") #{translate("requesting_password_reset")}…
|
| #{translate("request_password_reset")}
|
||||||
|
span(hidden data-ol-inflight-text)
|
||||||
|
| #{translate("requesting_password_reset")}…
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-md-6.col-md-offset-3.col-lg-4.col-lg-offset-4
|
.col-md-6.col-md-offset-3.col-lg-4.col-lg-offset-4
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
extends ../layout
|
extends ../layout-marketing
|
||||||
include ../_mixins/recaptcha
|
include ../_mixins/recaptcha
|
||||||
|
|
||||||
block content
|
block content
|
||||||
|
@ -25,18 +25,17 @@ block content
|
||||||
a(href=`mailto:${settings.adminEmail}`, ng-non-bindable) #{settings.adminEmail}
|
a(href=`mailto:${settings.adminEmail}`, ng-non-bindable) #{settings.adminEmail}
|
||||||
| .
|
| .
|
||||||
form(
|
form(
|
||||||
async-form="reconfirm-account-request",
|
data-ol-form
|
||||||
name="reconfirmAccountForm"
|
name="reconfirmAccountForm"
|
||||||
action="/user/reconfirm",
|
action="/user/reconfirm",
|
||||||
method="POST",
|
method="POST",
|
||||||
ng-cloak
|
|
||||||
ng-init="email='"+email+"'"
|
|
||||||
aria-label=translate('request_reconfirmation_email')
|
aria-label=translate('request_reconfirmation_email')
|
||||||
captcha=(showCaptcha ? '' : false),
|
captcha=(showCaptcha ? '' : false),
|
||||||
captcha-action-name=(showCaptcha ? "passwordReset" : false),
|
captcha-action-name=(showCaptcha ? "passwordReset" : false)
|
||||||
)
|
)
|
||||||
|
div(data-ol-form-messages)
|
||||||
|
|
||||||
input(type="hidden", name="_csrf", value=csrfToken)
|
input(type="hidden", name="_csrf", value=csrfToken)
|
||||||
form-messages(for="reconfirmAccountForm" role="alert")
|
|
||||||
.form-group
|
.form-group
|
||||||
label(for='email') #{translate("please_enter_email")}
|
label(for='email') #{translate("please_enter_email")}
|
||||||
input.form-control(
|
input.form-control(
|
||||||
|
@ -45,18 +44,19 @@ block content
|
||||||
name='email',
|
name='email',
|
||||||
placeholder='email@example.com',
|
placeholder='email@example.com',
|
||||||
required,
|
required,
|
||||||
ng-model="email",
|
|
||||||
autofocus
|
autofocus
|
||||||
|
value=email
|
||||||
)
|
)
|
||||||
span.small.text-primary(
|
|
||||||
ng-show="reconfirmAccountForm.email.$invalid && reconfirmAccountForm.email.$dirty"
|
|
||||||
) #{translate("must_be_email_address")}
|
|
||||||
.actions
|
.actions
|
||||||
button.btn.btn-primary(
|
button.btn.btn-primary(
|
||||||
type='submit',
|
type='submit',
|
||||||
ng-disabled="reconfirmAccountForm.$invalid"
|
data-ol-disabled-inflight,
|
||||||
aria-label=translate('request_password_reset_to_reconfirm')
|
aria-label=translate('request_password_reset_to_reconfirm')
|
||||||
) #{translate('request_password_reset_to_reconfirm')}
|
)
|
||||||
|
span(data-ol-not-inflight-text)
|
||||||
|
| #{translate('request_password_reset_to_reconfirm')}
|
||||||
|
span(hidden data-ol-inflight-text)
|
||||||
|
| #{translate('request_password_reset_to_reconfirm')}…
|
||||||
.row
|
.row
|
||||||
.col-sm-12.col-md-6.col-md-offset-3
|
.col-sm-12.col-md-6.col-md-offset-3
|
||||||
if showCaptcha
|
if showCaptcha
|
||||||
|
|
|
@ -68,6 +68,9 @@ describe('PasswordResetController', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('requestReset', function () {
|
describe('requestReset', function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
this.res.json = sinon.stub()
|
||||||
|
})
|
||||||
it('should tell the handler to process that email', function (done) {
|
it('should tell the handler to process that email', function (done) {
|
||||||
this.PasswordResetHandler.generateAndEmailResetToken.callsArgWith(
|
this.PasswordResetHandler.generateAndEmailResetToken.callsArgWith(
|
||||||
1,
|
1,
|
||||||
|
@ -79,6 +82,7 @@ describe('PasswordResetController', function () {
|
||||||
.calledWith(this.email)
|
.calledWith(this.email)
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
this.res.statusCode.should.equal(200)
|
this.res.statusCode.should.equal(200)
|
||||||
|
this.res.json.calledWith(sinon.match.has('message')).should.equal(true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -101,6 +105,7 @@ describe('PasswordResetController', function () {
|
||||||
)
|
)
|
||||||
this.PasswordResetController.requestReset(this.req, this.res)
|
this.PasswordResetController.requestReset(this.req, this.res)
|
||||||
this.res.statusCode.should.equal(404)
|
this.res.statusCode.should.equal(404)
|
||||||
|
this.res.json.calledWith(sinon.match.has('message')).should.equal(true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -112,6 +117,7 @@ describe('PasswordResetController', function () {
|
||||||
)
|
)
|
||||||
this.PasswordResetController.requestReset(this.req, this.res)
|
this.PasswordResetController.requestReset(this.req, this.res)
|
||||||
this.res.statusCode.should.equal(404)
|
this.res.statusCode.should.equal(404)
|
||||||
|
this.res.json.calledWith(sinon.match.has('message')).should.equal(true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -128,6 +134,7 @@ describe('PasswordResetController', function () {
|
||||||
.calledWith(this.email.toLowerCase().trim())
|
.calledWith(this.email.toLowerCase().trim())
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
this.res.statusCode.should.equal(200)
|
this.res.statusCode.should.equal(200)
|
||||||
|
this.res.json.calledWith(sinon.match.has('message')).should.equal(true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue