Created
January 30, 2017 14:08
-
-
Save travist/23f16a361da87b35b796d9a379321ef9 to your computer and use it in GitHub Desktop.
Reset Password Workflow with Form.io
This file contains hidden or 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
| <h3>Please provide your new password to reset your password.</h3> | |
| <formio form="form"></formio> |
This file contains hidden or 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
| (function() { | |
| 'use strict'; | |
| angular | |
| .module('myApp') | |
| .config(routerConfig); | |
| /** @ngInject */ | |
| function routerConfig( | |
| $stateProvider, | |
| $urlRouterProvider, | |
| FormioResourceProvider, | |
| FormioFormBuilderProvider, | |
| AppConfig, | |
| $injector | |
| ) { | |
| $stateProvider | |
| .state('auth/reset', { | |
| url: '/reset', | |
| templateUrl: 'sendreset.html', | |
| controller: ['$scope', function($scope) { | |
| $scope.resetSent = false; | |
| $scope.$on('formSubmission', function() { | |
| $scope.resetSent = true; | |
| }); | |
| }] | |
| }) | |
| .state('changepass', { | |
| url: '/changepass', | |
| templateUrl: 'changepass.html', | |
| controller: ['$scope', '$state', '$rootScope', 'Formio', 'AppConfig', function($scope, $state, $rootScope, Formio, AppConfig) { | |
| $scope.form = null; | |
| (new Formio(AppConfig.forms.changePasswordForm)).loadform().then(function(form) { | |
| $scope.form = form; | |
| }); | |
| $scope.$on('formSubmission', function(event, submission) { | |
| $rootScope.user.data.password = submission.data.password; | |
| var submissionUrl = AppConfig.resources.user.form + '/submission/' + $rootScope.user._id; | |
| (new Formio(submissionUrl)).saveSubmission($rootScope.user).then(function() { | |
| $state.go('home'); | |
| }); | |
| }); | |
| }] | |
| }); | |
| } | |
| })(); |
This file contains hidden or 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
| <h3>Please click on the following link to reset your password.</h3> | |
| <br/> | |
| <a href="http://myapp.com?token=[[token(data.email=user)]]#changepass" class="btn-primary">Change Password</a> |
This file contains hidden or 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
| <formio src="sendResetForm" ng-if="!resetSent"></formio> | |
| <div class="well" ng-if="resetSent"> | |
| <p>We have sent you an email to reset your password.</p> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment