Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Commit ca5220d

Browse files
committed
Added forgot password / reset password module
1 parent 8a320eb commit ca5220d

26 files changed

+885
-87
lines changed

CHANGELOG.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1-
### v0.0.1
1+
# Change Log
22

3-
+ Initial Commit
3+
## [v0.1.1](https://github.com/silverbux/laravel-angular-admin/tree/v0.1.1) (2016-05-23)
4+
[Full Changelog](https://github.com/silverbux/laravel-angular-admin/compare/v0.1.0...v0.1.1)
5+
6+
**Merged pull requests:**
7+
8+
- Added forgot password / reset password module [\#18](https://github.com/silverbux/laravel-angular-admin/pull/18) ([silverbux](https://github.com/silverbux))
9+
- User Profile [\#17](https://github.com/silverbux/laravel-angular-admin/pull/17) ([silverbux](https://github.com/silverbux))
10+
11+
## [v0.1.0](https://github.com/silverbux/laravel-angular-admin/tree/v0.1.0) (2016-05-20)
12+
**Merged pull requests:**
13+
14+
- Added Database Seeders [\#16](https://github.com/silverbux/laravel-angular-admin/pull/16) ([silverbux](https://github.com/silverbux))
15+
- User email verification [\#15](https://github.com/silverbux/laravel-angular-admin/pull/15) ([silverbux](https://github.com/silverbux))
16+
- Ability to set role permissions [\#14](https://github.com/silverbux/laravel-angular-admin/pull/14) ([silverbux](https://github.com/silverbux))
17+
- Updating demo [\#13](https://github.com/silverbux/laravel-angular-admin/pull/13) ([silverbux](https://github.com/silverbux))
18+
- Users List/ Edit and Role Settings [\#12](https://github.com/silverbux/laravel-angular-admin/pull/12) ([silverbux](https://github.com/silverbux))
19+
- User Permission Module [\#11](https://github.com/silverbux/laravel-angular-admin/pull/11) ([silverbux](https://github.com/silverbux))
20+
- Going for standardjs [\#9](https://github.com/silverbux/laravel-angular-admin/pull/9) ([silverbux](https://github.com/silverbux))
21+
- Access control list [\#8](https://github.com/silverbux/laravel-angular-admin/pull/8) ([silverbux](https://github.com/silverbux))
22+
- Access control list [\#7](https://github.com/silverbux/laravel-angular-admin/pull/7) ([silverbux](https://github.com/silverbux))
23+
- Merge pull request \#4 from silverbux/master [\#5](https://github.com/silverbux/laravel-angular-admin/pull/5) ([silverbux](https://github.com/silverbux))
24+
- production parameter + elixir [\#4](https://github.com/silverbux/laravel-angular-admin/pull/4) ([silverbux](https://github.com/silverbux))
25+
- Heroku [\#3](https://github.com/silverbux/laravel-angular-admin/pull/3) ([silverbux](https://github.com/silverbux))
26+
- Heroku Deployment [\#2](https://github.com/silverbux/laravel-angular-admin/pull/2) ([silverbux](https://github.com/silverbux))
27+
- Heroku [\#1](https://github.com/silverbux/laravel-angular-admin/pull/1) ([silverbux](https://github.com/silverbux))
28+
29+
30+
31+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<form ng-submit="vm.submit()" class="ForgotPassword-form">
2+
<div class="callout callout-danger" ng-if="vm.errorTrigger">
3+
<h4>Error:</h4>
4+
<p>Please check your email and try again.</p>
5+
</div>
6+
<div class="form-group has-feedback">
7+
<input type="email" class="form-control" placeholder="Please enter your email address" ng-model="vm.email">
8+
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
9+
</div>
10+
<div class="row">
11+
<div class="col-xs-8">
12+
</div>
13+
<div class="col-xs-4">
14+
<button type="submit" class="btn btn-primary btn-block btn-flat">Submit</button>
15+
</div>
16+
</div>
17+
</form>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class ForgotPasswordController {
2+
constructor (API, $state) {
3+
'ngInject'
4+
5+
this.API = API
6+
this.$state = $state
7+
this.errorTrigger = false
8+
}
9+
10+
$onInit () {
11+
this.email = ''
12+
}
13+
14+
submit () {
15+
this.API.all('auth/password/email').post({
16+
email: this.email
17+
}).then(() => {
18+
this.$state.go('login', { successMsg: `Please check your email for instructions on how to reset your password.` })
19+
}, () => {
20+
this.errorTrigger = true
21+
})
22+
}
23+
}
24+
25+
export const ForgotPasswordComponent = {
26+
templateUrl: './views/app/components/forgot-password/forgot-password.component.html',
27+
controller: ForgotPasswordController,
28+
controllerAs: 'vm',
29+
bindings: {}
30+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.ForgotPassword-input{
2+
margin-bottom: 0;
3+
}

angular/app/components/login-form/login-form.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ <h4>Email Unverified</h4>
1111
<h4>Registration Success!</h4>
1212
<p>A verification link has been sent to your Email Account. Thank You!</p>
1313
</div>
14+
<div class="callout callout-success" ng-if="vm.successMsg">
15+
<h4>Success!</h4>
16+
<p>{{ vm.successMsg }}</p>
17+
</div>
1418
<div class="form-group has-feedback">
1519
<input type="email" class="form-control" placeholder="Email" ng-model="vm.email">
1620
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
@@ -34,6 +38,6 @@ <h4>Registration Success!</h4>
3438
<a href="/auth/google" class="btn btn-block btn-social btn-google btn-flat"><i class="fa fa-google"></i> Sign in using Google</a>
3539
<a href="/auth/facebook" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> Sign in using Facebook</a>
3640
</div>
37-
<a href="#">I forgot my password</a>
41+
<a ui-sref="forgot_password">I forgot my password</a>
3842
<br>
3943
<a ui-sref="register" class="text-center">Register a new membership</a>

angular/app/components/login-form/login-form.component.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class LoginFormController {
88
this.AclService = AclService
99

1010
this.registerSuccess = $stateParams.registerSuccess
11+
this.successMsg = $stateParams.successMsg
1112
this.loginfailed = false
1213
this.unverified = false
1314
this.email = ''

angular/app/components/password-verify/password-verify.component.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
function passwordVerifyClass () {
22
return {
3-
require: "ngModel",
3+
require: 'ngModel',
44
scope: {
55
passwordVerify: '='
66
},
7-
link: function(scope, element, attrs, ctrl) {
8-
scope.$watch(function() {
9-
var combined;
7+
link: function (scope, element, attrs, ctrl) {
8+
scope.$watch(function () {
9+
var combined
1010

1111
if (scope.passwordVerify || ctrl.$viewValue) {
12-
combined = scope.passwordVerify + '_' + ctrl.$viewValue;
12+
combined = scope.passwordVerify + '_' + ctrl.$viewValue
1313
}
1414

15-
return combined;
16-
}, function(value) {
15+
return combined
16+
}, function (value) {
1717
if (value) {
18-
ctrl.$parsers.unshift(function(viewValue) {
19-
var origin = scope.passwordVerify;
18+
ctrl.$parsers.unshift(function (viewValue) {
19+
var origin = scope.passwordVerify
2020

2121
if (origin !== viewValue) {
22-
ctrl.$setValidity("passwordVerify", false);
23-
return undefined;
22+
ctrl.$setValidity('passwordVerify', false)
23+
return undefined
2424
} else {
25-
ctrl.$setValidity("passwordVerify", true);
26-
return viewValue;
25+
ctrl.$setValidity('passwordVerify', true)
26+
return viewValue
2727
}
28-
});
28+
})
2929
}
30-
});
30+
})
3131
}
3232
}
3333
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<form ng-submit="vm.submit()">
2+
<div ng-if="!vm.isValidToken" layout="row" layout-align="center center">
3+
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
4+
</div>
5+
<div ng-if="vm.alerts" class="alert alert-{{alert.type}}" ng-repeat="alert in vm.alerts">
6+
<h4>{{alert.title}}</h4>
7+
<p ng-bind-html="alert.msg | trustHtml"></p>
8+
</div>
9+
<div ng-show="vm.isValidToken">
10+
<div class="form-group has-feedback">
11+
<input type="password" ng-model="vm.password" class="form-control" placeholder="Please enter your new password">
12+
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
13+
</div>
14+
<div class="form-group has-feedback">
15+
<input type="password" ng-model="vm.password_confirmation" class="form-control" placeholder="Please confirm your new password">
16+
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
17+
</div>
18+
19+
<div class="row">
20+
<div class="col-xs-8">
21+
</div>
22+
<div class="col-xs-4">
23+
<button type="submit" class="btn btn-primary btn-block btn-flat">Submit</button>
24+
</div>
25+
</div>
26+
</div>
27+
</form>
28+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
class ResetPasswordController {
2+
constructor (API, $state) {
3+
'ngInject'
4+
5+
this.API = API
6+
this.$state = $state
7+
this.alerts = []
8+
}
9+
10+
$onInit () {
11+
this.password = ''
12+
this.password_confirmation = ''
13+
this.isValidToken = false
14+
15+
this.verifyToken()
16+
}
17+
18+
verifyToken () {
19+
let email = this.$state.params.email
20+
let token = this.$state.params.token
21+
22+
this.API.all('auth/password').get('verify', {
23+
email, token}).then(() => {
24+
this.isValidToken = true
25+
}, () => {
26+
this.$state.go('app.landing')
27+
})
28+
}
29+
30+
submit () {
31+
this.alerts = []
32+
let data = {
33+
email: this.$state.params.email,
34+
token: this.$state.params.token,
35+
password: this.password,
36+
password_confirmation: this.password_confirmation
37+
}
38+
39+
this.API.all('auth/password/reset').post(data).then(() => {
40+
this.$state.go('login', { successMsg: `Your password has been changed, You may now login.` })
41+
}, (res) => {
42+
let alrtArr = []
43+
44+
angular.forEach(res.data.errors, function (value) {
45+
alrtArr = { type: 'error', 'title': 'Error!', msg: value[0]}
46+
})
47+
48+
this.alerts.push(alrtArr)
49+
})
50+
}
51+
}
52+
53+
export const ResetPasswordComponent = {
54+
templateUrl: './views/app/components/reset-password/reset-password.component.html',
55+
controller: ResetPasswordController,
56+
controllerAs: 'vm',
57+
bindings: {}
58+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.ResetPassword-input{
2+
margin-bottom: 0;
3+
}
Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,62 @@
1-
class UserProfileController{
2-
constructor($stateParams, $state, API){
3-
'ngInject';
1+
class UserProfileController {
2+
constructor ($stateParams, $state, API) {
3+
'ngInject'
44

5-
this.$state = $state
6-
this.formSubmitted = false
7-
this.alerts = []
8-
this.userRolesSelected = []
5+
this.$state = $state
6+
this.formSubmitted = false
7+
this.alerts = []
8+
this.userRolesSelected = []
99

10-
if ($stateParams.alerts) {
11-
this.alerts.push($stateParams.alerts)
12-
}
13-
14-
let UserData = API.service('me', API.all('users'))
15-
UserData.one().get()
16-
.then((response) => {
17-
this.userdata = API.copy(response)
18-
this.userdata.data.current_password = ''
19-
this.userdata.data.new_password = ''
20-
this.userdata.data.new_password_confirmation = ''
21-
})
10+
if ($stateParams.alerts) {
11+
this.alerts.push($stateParams.alerts)
2212
}
2313

24-
save (isValid, userForm) {
25-
if (isValid) {
26-
let $state = this.$state
27-
28-
this.userdata.put()
29-
.then(() => {
30-
let alert = { type: 'success', 'title': 'Success!', msg: 'Profile has been updated.' }
31-
$state.go($state.current, { alerts: alert})
32-
}, (response) => {
33-
let formErrors = []
34-
35-
if(angular.isDefined(response.data.errors.message)) {
36-
formErrors = response.data.errors.message[0];
37-
} else {
38-
formErrors = response.data.errors;
39-
}
40-
41-
angular.forEach(formErrors, function(value, key) {
42-
let varkey = key.replace("data.", "")
43-
userForm[varkey].$invalid = true;
44-
userForm[varkey].customError = value[0];
45-
});
46-
47-
this.formSubmitted = true;
14+
let UserData = API.service('me', API.all('users'))
15+
UserData.one().get()
16+
.then((response) => {
17+
this.userdata = API.copy(response)
18+
this.userdata.data.current_password = ''
19+
this.userdata.data.new_password = ''
20+
this.userdata.data.new_password_confirmation = ''
21+
})
22+
}
23+
24+
save (isValid, userForm) {
25+
if (isValid) {
26+
let $state = this.$state
27+
28+
this.userdata.put()
29+
.then(() => {
30+
let alert = { type: 'success', 'title': 'Success!', msg: 'Profile has been updated.' }
31+
$state.go($state.current, { alerts: alert})
32+
}, (response) => {
33+
let formErrors = []
34+
35+
if (angular.isDefined(response.data.errors.message)) {
36+
formErrors = response.data.errors.message[0]
37+
} else {
38+
formErrors = response.data.errors
39+
}
40+
41+
angular.forEach(formErrors, function (value, key) {
42+
let varkey = key.replace('data.', '')
43+
userForm[varkey].$invalid = true
44+
userForm[varkey].customError = value[0]
4845
})
49-
} else {
50-
this.formSubmitted = true;
51-
}
52-
}
5346

54-
$onInit(){
47+
this.formSubmitted = true
48+
})
49+
} else {
50+
this.formSubmitted = true
5551
}
52+
}
53+
54+
$onInit () {}
5655
}
5756

5857
export const UserProfileComponent = {
59-
templateUrl: './views/app/components/user-profile/user-profile.component.html',
60-
controller: UserProfileController,
61-
controllerAs: 'vm',
62-
bindings: {}
58+
templateUrl: './views/app/components/user-profile/user-profile.component.html',
59+
controller: UserProfileController,
60+
controllerAs: 'vm',
61+
bindings: {}
6362
}
64-
65-
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.ForgotPassword-formContainer{
2+
margin-top: 80px;
3+
margin-bottom: 80px;
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div class="login-box">
2+
<div class="login-logo">
3+
<a ui-sref="login"><b>Admin</b>LTE</a>
4+
</div>
5+
<div class="login-box-body">
6+
<h3>Forgot your password?</h3>
7+
<forgot-password></forgot-password>
8+
<a ui-sref="login">Back to Login Page</a>
9+
</div>
10+
</div>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.ResetPassword-formContainer{
2+
margin-top: 80px;
3+
margin-bottom: 80px;
4+
}

0 commit comments

Comments
 (0)