Skip to content

Commit

Permalink
Error handling for password reset
Browse files Browse the repository at this point in the history
  • Loading branch information
rheasunshine authored and adamaziz15 committed Oct 2, 2017
1 parent bb502ed commit aac66df
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 12 deletions.
45 changes: 36 additions & 9 deletions src/app/views/auth/password/reset.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,56 @@ angular.module('mnoEnterpriseAngular')
$pwdScore: {}
}

if !$location.search().reset_password_token
toastr.error('devise.passwords.no_token', {
timeOut: 0,
closeButton: true,
extendedTimeOut: 0
})
$state.go('password_recovery')

vm.password_reset = ->
if vm.form.$invalid && !MnoErrorsHandler.onlyServerError(vm.form)
return
else if vm.user.password != vm.user.password_confirmation
toastr.error('Passwords do not match.')
vm.hasClicked = false
return

MnoErrorsHandler.resetErrors(vm.form)

vm.user.reset_password_token = $location.search().reset_password_token
Auth.resetPassword(vm.user).then(
->
toastr.info('devise.passwords.updated', {
timeOut: 0,
closeButton: true,
extendedTimeOut: 0
})
vm.resetConfirmed = true
Auth.login(vm.user).then(
->
toastr.success('devise.passwords.updated', {
timeOut: 10000,
closeButton: true,
})
$state.go('home.impac')
).finally( -> vm.resetConfirmed = true)
(error) ->
MnoErrorsHandler.processServerError(error, vm.form)
).finally( -> vm.hasClicked = false)
(error) ->
toastr.success('devise.passwords.updated_not_active', {
timeOut: 10000,
closeButton: true,
})
)
).catch(
(error) ->
if error.status == 422
toastr.info('devise.passwords.already_reset_error', {
timeOut: 10000,
closeButton: true,
})
$state.go('login')
else
toastr.error('devise.passwords.unspecified_reset_error', {
timeOut: 10000,
closeButton: true,
})
MnoErrorsHandler.processServerError(error, vm.form)
).finally( -> vm.hasClicked = false)

return true

Expand Down
2 changes: 1 addition & 1 deletion src/app/views/auth/password/reset.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2>{{ 'mno_enterprise.auth.passwords.edit.title' | translate }}</h2>
<div class='col-sm-12'>
<div class="input-group">
<input mno-password-strength password-score="vm.user.$pwdScore" type="{{isShown ? 'text' : 'password'}}" placeholder="*Password" ng-model="vm.user.password" class="form-control" name="password" id="user_password" autocomplete="off" autofocus required/>
<span class="input-group-addon pw-strength-indicator" ng-class='vm.user.$pwdScore.class'>
<span class="input-group-addon pw-strength-indicator" ng-class='vm.user.$pwdScore.class' uib-tooltip="{{'activemodel.errors.mno_enterprise/user.password_weak' | translate}}" tooltip-enable="vm.user.$pwdScore.value == 'weak'" tooltip-placement="auto">
{{ vm.user.$pwdScore.value }}
</span>
</div>
Expand Down
155 changes: 153 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,15 @@
"devise.mailer.password_change.subject": "Password Changed",
"devise.omniauth_callbacks.failure": "Could not authenticate you from %{kind} because \"%{reason}\".",
"devise.omniauth_callbacks.success": "Successfully authenticated from %{kind} account.",
"devise.passwords.no_token": "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided.",
"devise.passwords.no_token": "You can't access that page without coming from a password reset email. Please make sure you used the full URL provided in the email, or enter your email here to receive a new link.",
"devise.passwords.send_instructions": "You will receive an email with instructions on how to reset your password in a few minutes.",
"devise.passwords.send_paranoid_instructions": "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes.",
"devise.passwords.updated": "Your password has been changed successfully. You are now signed in.",
"devise.passwords.updated_not_active": "Your password has been changed successfully.",
"devise.passwords.do_not_match_error": "Your passwords do not match",
"devise.passwords.confirmation_password_required": "You must enter a password and password confirmation.",
"devise.passwords.already_reset_error": "Your password has already been reset. Log in!",
"devise.passwords.unspecified_reset_error": "Oops, something went wrong... Try again",
"devise.registrations.destroyed": "Bye! Your account has been successfully cancelled. We hope to see you again soon.",
"devise.registrations.signed_up": "Welcome! You have signed up successfully.",
"devise.registrations.signed_up_but_inactive": "You have signed up successfully. However, we could not sign you in because your account is not yet activated.",
Expand Down Expand Up @@ -1239,5 +1243,152 @@
"mno_enterprise.provision.select_organization.title": "Choose an organization",
"mno_enterprise.provision.select_organization.explanation": "You belong to multiple organizations",
"mno_enterprise.provision.select_organization.select": "Please select the organization you are making this new order for",
"mno_enterprise.provision.select_organization.submit": "Go"
"mno_enterprise.provision.select_organization.submit": "Go",
"activemodel.models.mno_enterprise/app": "App",
"activemodel.models.mno_enterprise/app_instance": "App instance",
"activemodel.models.mno_enterprise/credit_card": "Credit card",
"activemodel.models.mno_enterprise/deletion_request": "Deletion request",
"activemodel.models.mno_enterprise/impac/dashboard": "Dashboard",
"activemodel.models.mno_enterprise/impac/widget": "Widget",
"activemodel.models.mno_enterprise/invoice": "Invoice",
"activemodel.models.mno_enterprise/org_invite": "Org invite",
"activemodel.models.mno_enterprise/org_team": "Org team",
"activemodel.models.mno_enterprise/organization": "Organization",
"activemodel.models.mno_enterprise/user": "User",
"activemodel.attributes.mno_enterprise/app.categories": "Categories",
"activemodel.attributes.mno_enterprise/app.created_at": "Created at",
"activemodel.attributes.mno_enterprise/app.description": "Description",
"activemodel.attributes.mno_enterprise/app.id": "Id",
"activemodel.attributes.mno_enterprise/app.key_benefits": "Key benefits",
"activemodel.attributes.mno_enterprise/app.key_features": "Key features",
"activemodel.attributes.mno_enterprise/app.logo": "Logo",
"activemodel.attributes.mno_enterprise/app.name": "Name",
"activemodel.attributes.mno_enterprise/app.nid": "Nid",
"activemodel.attributes.mno_enterprise/app.pictures": "Pictures",
"activemodel.attributes.mno_enterprise/app.popup_description": "Popup description",
"activemodel.attributes.mno_enterprise/app.slug": "Slug",
"activemodel.attributes.mno_enterprise/app.stack": "Stack",
"activemodel.attributes.mno_enterprise/app.terms_url": "Link to terms of use",
"activemodel.attributes.mno_enterprise/app.testimonials": "Testimonials",
"activemodel.attributes.mno_enterprise/app.tiny_description": "Short description",
"activemodel.attributes.mno_enterprise/app.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/app.website": "Website",
"activemodel.attributes.mno_enterprise/app.worldwide_usage": "Worldwide usage",
"activemodel.attributes.mno_enterprise/app_instance.app_id": "App",
"activemodel.attributes.mno_enterprise/app_instance.autostop_at": "Autostop at",
"activemodel.attributes.mno_enterprise/app_instance.autostop_interval": "Autostop interval",
"activemodel.attributes.mno_enterprise/app_instance.billing_type": "Billing type",
"activemodel.attributes.mno_enterprise/app_instance.created_at": "Created at",
"activemodel.attributes.mno_enterprise/app_instance.id": "Id",
"activemodel.attributes.mno_enterprise/app_instance.name": "Name",
"activemodel.attributes.mno_enterprise/app_instance.next_status": "Next status",
"activemodel.attributes.mno_enterprise/app_instance.owner_id": "Owner",
"activemodel.attributes.mno_enterprise/app_instance.owner_type": "Owner type",
"activemodel.attributes.mno_enterprise/app_instance.soa_enabled": "Soa enabled",
"activemodel.attributes.mno_enterprise/app_instance.stack": "Stack",
"activemodel.attributes.mno_enterprise/app_instance.started_at": "Started at",
"activemodel.attributes.mno_enterprise/app_instance.status": "Status",
"activemodel.attributes.mno_enterprise/app_instance.stopped_at": "Stopped at",
"activemodel.attributes.mno_enterprise/app_instance.terminated_at": "Terminated at",
"activemodel.attributes.mno_enterprise/app_instance.uid": "Uid",
"activemodel.attributes.mno_enterprise/app_instance.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/credit_card.billing_address": "Billing address",
"activemodel.attributes.mno_enterprise/credit_card.billing_city": "City",
"activemodel.attributes.mno_enterprise/credit_card.billing_country": "Country",
"activemodel.attributes.mno_enterprise/credit_card.billing_postcode": "Postcode",
"activemodel.attributes.mno_enterprise/credit_card.country": "Country",
"activemodel.attributes.mno_enterprise/credit_card.created_at": "Created at",
"activemodel.attributes.mno_enterprise/credit_card.first_name": "First name",
"activemodel.attributes.mno_enterprise/credit_card.id": "Id",
"activemodel.attributes.mno_enterprise/credit_card.last_name": "Last name",
"activemodel.attributes.mno_enterprise/credit_card.masked_number": "Masked number",
"activemodel.attributes.mno_enterprise/credit_card.month": "Month",
"activemodel.attributes.mno_enterprise/credit_card.number": "Number",
"activemodel.attributes.mno_enterprise/credit_card.organization_id": "Organization",
"activemodel.attributes.mno_enterprise/credit_card.title": "Title",
"activemodel.attributes.mno_enterprise/credit_card.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/credit_card.verification_value": "CVV",
"activemodel.attributes.mno_enterprise/credit_card.year": "Year",
"activemodel.attributes.mno_enterprise/deletion_request.created_at": "Created at",
"activemodel.attributes.mno_enterprise/deletion_request.id": "Id",
"activemodel.attributes.mno_enterprise/deletion_request.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/impac/dashboard.created_at": "Created at",
"activemodel.attributes.mno_enterprise/impac/dashboard.id": "Id",
"activemodel.attributes.mno_enterprise/impac/dashboard.name": "Name",
"activemodel.attributes.mno_enterprise/impac/dashboard.organization_ids": "Organizations",
"activemodel.attributes.mno_enterprise/impac/dashboard.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/impac/dashboard.widgets_order": "Widgets order",
"activemodel.attributes.mno_enterprise/impac/dashboard.widgets_templates": "Widgets templates",
"activemodel.attributes.mno_enterprise/impac/widget.created_at": "Created at",
"activemodel.attributes.mno_enterprise/impac/widget.id": "Id",
"activemodel.attributes.mno_enterprise/impac/widget.name": "Name",
"activemodel.attributes.mno_enterprise/impac/widget.settings": "Settings",
"activemodel.attributes.mno_enterprise/impac/widget.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/impac/widget.widget_category": "Widget category",
"activemodel.attributes.mno_enterprise/impac/widget.width": "Width",
"activemodel.attributes.mno_enterprise/invoice.created_at": "Created at",
"activemodel.attributes.mno_enterprise/invoice.id": "Id",
"activemodel.attributes.mno_enterprise/invoice.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/org_invite.created_at": "Created at",
"activemodel.attributes.mno_enterprise/org_invite.id": "Id",
"activemodel.attributes.mno_enterprise/org_invite.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/org_team.created_at": "Created at",
"activemodel.attributes.mno_enterprise/org_team.id": "Id",
"activemodel.attributes.mno_enterprise/org_team.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/organization.account_frozen": "Account frozen?",
"activemodel.attributes.mno_enterprise/organization.created_at": "Created at",
"activemodel.attributes.mno_enterprise/organization.free_trial_end_at": "Free trial end at",
"activemodel.attributes.mno_enterprise/organization.geo_city": "City",
"activemodel.attributes.mno_enterprise/organization.geo_country_code": "Country code",
"activemodel.attributes.mno_enterprise/organization.geo_currency": "Currency",
"activemodel.attributes.mno_enterprise/organization.geo_state_code": "State code",
"activemodel.attributes.mno_enterprise/organization.geo_tz": "Timezone",
"activemodel.attributes.mno_enterprise/organization.id": "Id",
"activemodel.attributes.mno_enterprise/organization.latitude": "Latitude",
"activemodel.attributes.mno_enterprise/organization.logo": "Logo",
"activemodel.attributes.mno_enterprise/organization.longitude": "Longitude",
"activemodel.attributes.mno_enterprise/organization.mails": "Contact emails",
"activemodel.attributes.mno_enterprise/organization.meta_data": "Metadata",
"activemodel.attributes.mno_enterprise/organization.name": "Name",
"activemodel.attributes.mno_enterprise/organization.soa_enabled": "Connec!™ enabled",
"activemodel.attributes.mno_enterprise/organization.uid": "Uid",
"activemodel.attributes.mno_enterprise/organization.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/user.authenticatable_salt": "Authenticatable salt",
"activemodel.attributes.mno_enterprise/user.company": "Company",
"activemodel.attributes.mno_enterprise/user.confirmation_sent_at": "Confirmation sent at",
"activemodel.attributes.mno_enterprise/user.confirmation_token": "Confirmation token",
"activemodel.attributes.mno_enterprise/user.confirmed_at": "Confirmed at",
"activemodel.attributes.mno_enterprise/user.created_at": "Created at",
"activemodel.attributes.mno_enterprise/user.current_password": "Current password",
"activemodel.attributes.mno_enterprise/user.current_sign_in_at": "Current sign in at",
"activemodel.attributes.mno_enterprise/user.current_sign_in_ip": "Current sign in ip",
"activemodel.attributes.mno_enterprise/user.email": "Email",
"activemodel.attributes.mno_enterprise/user.encrypted_password": "Encrypted password",
"activemodel.attributes.mno_enterprise/user.failed_attempts": "Failed attempts",
"activemodel.attributes.mno_enterprise/user.geo_city": "City",
"activemodel.attributes.mno_enterprise/user.geo_country_code": "Country",
"activemodel.attributes.mno_enterprise/user.geo_state_code": "State code",
"activemodel.attributes.mno_enterprise/user.id": "Id",
"activemodel.attributes.mno_enterprise/user.last_sign_in_at": "Last sign in at",
"activemodel.attributes.mno_enterprise/user.last_sign_in_ip": "Last sign in ip",
"activemodel.attributes.mno_enterprise/user.locked_at": "Locked at",
"activemodel.attributes.mno_enterprise/user.name": "First name",
"activemodel.attributes.mno_enterprise/user.password": "Password",
"activemodel.attributes.mno_enterprise/user.password_confirmation": "Password confirmation",
"activemodel.attributes.mno_enterprise/user.phone": "Phone",
"activemodel.attributes.mno_enterprise/user.phone_country_code": "Ext.",
"activemodel.attributes.mno_enterprise/user.remember_me": "Remember me",
"activemodel.attributes.mno_enterprise/user.remember_created_at": "Remember created at",
"activemodel.attributes.mno_enterprise/user.reset_password_sent_at": "Reset password sent at",
"activemodel.attributes.mno_enterprise/user.reset_password_token": "Reset password token",
"activemodel.attributes.mno_enterprise/user.sign_in_count": "Login count",
"activemodel.attributes.mno_enterprise/user.sso_session": "Sso session",
"activemodel.attributes.mno_enterprise/user.surname": "Surname",
"activemodel.attributes.mno_enterprise/user.uid": "Uid",
"activemodel.attributes.mno_enterprise/user.unconfirmed_email": "Unconfirmed email",
"activemodel.attributes.mno_enterprise/user.unlock_token": "Unlock token",
"activemodel.attributes.mno_enterprise/user.updated_at": "Updated at",
"activemodel.attributes.mno_enterprise/user.website": "Website",
"activemodel.errors.models.mno_enterprise/user.attributes.email.taken": "has already been taken",
"activemodel.errors.mno_enterprise/user.password_weak": "Password is not strong enough. Try mixing letters, numbers and cases"
}

0 comments on commit aac66df

Please sign in to comment.