This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Password Reset #355
Merged
Merged
Password Reset #355
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dc9e168
Backend work for password reset
Ommy 9a03921
Set up password reset endpoints with verification
Ommy da59824
Created frontend for password reset
Ommy 575fb0f
Removed param fetcher helper and CR changes
Ommy 0b0571d
Added a timeout of 1000 to mocha
Ommy 6f1f53b
Changed event from submit to @ui.form submit
Ommy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
15 changes: 15 additions & 0 deletions
15
src-backbone/app/js/templates/auth/resetPasswordCompleteView.hbs
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<form> | ||
<div class="form-group"> | ||
<label for="new_password" class="sr-only">{{ i18n "New Password" }}</label> | ||
<input type="password" name="new_password" class="form-control" id="new_password" placeholder="New Password"> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="password_confirmation" class="sr-only">{{ i18n "Confirm Password" }}</label> | ||
<input type="password" name="password_confirmation" class="form-control" id="password_confirmation" placeholder="Confirm Password"> | ||
</div> | ||
|
||
<div> | ||
<button type="submit" class="btn btn-primary btn-block" id="submit-btn">{{ i18n "Change Password" }}</button> | ||
</div> | ||
</form> |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<form> | ||
<div class="form-group"> | ||
<label for="email" class="sr-only">{{ i18n "Email" }}</label> | ||
<input type="text" name="email" class="form-control" id="email" placeholder="Email"> | ||
</div> | ||
|
||
<div> | ||
<button type="submit" class="btn btn-primary btn-block" id="submit-btn">{{ i18n "Request Password Reset" }}</button> | ||
</div> | ||
</form> |
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
69 changes: 69 additions & 0 deletions
69
src-backbone/app/js/views/auth/resetPasswordCompleteView.js
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const App = require('utils/sanaAppInstance'); | ||
const Helpers = require('utils/helpers'); | ||
|
||
module.exports = Marionette.ItemView.extend({ | ||
|
||
initialize: function(reset_token) { | ||
this.token = reset_token.token; | ||
}, | ||
|
||
template: require('templates/auth/resetPasswordCompleteView'), | ||
|
||
ui: { | ||
form: 'form', | ||
}, | ||
|
||
events: { | ||
'submit @ui.form': 'onSubmit', | ||
}, | ||
|
||
onSubmit: function(event) { | ||
event.preventDefault(); | ||
|
||
let self = this; | ||
let $form = this.ui.form; | ||
|
||
self.completeReset($form.serializeArray()); | ||
}, | ||
|
||
completeReset: function(data) { | ||
let json = {}; | ||
data.forEach(function(item) { | ||
if (item.value !== "") { | ||
json[item.name] = item.value; | ||
} | ||
}); | ||
json.reset_token = this.token; | ||
|
||
$.ajax({ | ||
type: 'POST', | ||
url: '/api/passwords/reset_password_complete', | ||
data: JSON.stringify(json), | ||
beforeSend: function() { | ||
App().RootView.showSpinner(); | ||
}, | ||
complete: function() { | ||
App().RootView.hideSpinner(); | ||
}, | ||
success: function(response) { | ||
Helpers.navigateToDefaultLoggedOut(); | ||
App().RootView.clearNotifications(); | ||
App().RootView.showNotification({ | ||
title: 'Success!', | ||
desc: 'Password successfully reset!', | ||
alertType: 'success', | ||
}); | ||
}, | ||
error: function(errors) { | ||
App().RootView.clearNotifications(); | ||
Object.keys(errors.responseJSON).forEach(function(key) { | ||
App().RootView.showNotification({ | ||
title: 'There was a problem', | ||
desc: errors.responseJSON[key] | ||
}); | ||
}); | ||
} | ||
}); | ||
}, | ||
|
||
}); |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
let App = require('utils/sanaAppInstance'); | ||
const Helpers = require('utils/helpers'); | ||
|
||
module.exports = Marionette.ItemView.extend({ | ||
template: require('templates/auth/resetPasswordView'), | ||
|
||
ui: { | ||
form: 'form', | ||
}, | ||
|
||
events: { | ||
'submit @ui.form': 'onSubmit', | ||
}, | ||
|
||
onSubmit: function(event) { | ||
event.preventDefault(); | ||
|
||
let self = this; | ||
let $form = this.ui.form; | ||
|
||
self.resetPassword($form.serializeArray()); | ||
}, | ||
|
||
resetPassword: function(data) { | ||
let json = {}; | ||
data.forEach(function(item) { | ||
if (item.value !== "") { | ||
json[item.name] = item.value; | ||
} | ||
}); | ||
|
||
$.ajax({ | ||
type: 'POST', | ||
data: JSON.stringify(json), | ||
url: '/api/passwords/reset_password', | ||
beforeSend: function() { | ||
App().RootView.showSpinner(); | ||
}, | ||
complete: function() { | ||
App().RootView.hideSpinner(); | ||
}, | ||
success: function(response) { | ||
Helpers.navigateToDefaultLoggedOut(); | ||
App().RootView.clearNotifications(); | ||
App().RootView.showNotification({ | ||
title: 'Success!', | ||
desc: 'Email to reset password sent!', | ||
alertType: 'success', | ||
}); | ||
}, | ||
error: function(errors) { | ||
App().RootView.clearNotifications(); | ||
Object.keys(errors.responseJSON).forEach(function(key) { | ||
App().RootView.showNotification({ | ||
title: 'There was a problem', | ||
desc: errors.responseJSON[key] | ||
}); | ||
}); | ||
} | ||
}); | ||
}, | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Hello, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this file have an extension? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean we can always make it a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. k 👍 |
||
|
||
You requested your password to be reset. Please follow the link provided in order to complete the steps. You have 48 hours to reset your password. | ||
|
||
{{ link }} | ||
|
||
If you didn't request the password reset, just ignore this message. | ||
|
||
Thanks |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think we usually put
initialize
after the other definitions (in this case,template
,ui
, andevents
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no real convention but
initialize
at the beginning makes more sense. It is also how objects are defined on Backbone's site.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k 👍