tellform/public/modules/users/controllers/verify.client.controller.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2015-07-27 20:33:43 +00:00
'use strict';
angular.module('users').controller('VerifyController', ['$scope', '$state', '$rootScope', 'User', 'Auth', '$stateParams',
function($scope, $state, $rootScope, User, Auth, $stateParams) {
2015-07-28 22:29:07 +00:00
if($rootScope.authentication.isAuthenticated()){
2015-07-27 20:33:43 +00:00
$state.go('home');
}
$scope.isReset = false;
2015-07-29 00:16:44 +00:00
$scope.credentials = {};
2015-07-27 20:33:43 +00:00
// Submit forgotten password account id
$scope.resendVerifyEmail = function() {
2015-07-29 00:16:44 +00:00
console.log($scope.credentials.email);
User.resendVerifyEmail($scope.credentials.email).then(
2015-07-27 20:33:43 +00:00
function(response){
$scope.success = response.message;
$scope.credentials = null;
2015-07-28 22:29:07 +00:00
$scope.isResetSent = true;
2015-07-27 20:33:43 +00:00
},
function(error){
$scope.error = error;
$scope.credentials = null;
2015-07-28 22:29:07 +00:00
$scope.isReset = false;
2015-07-27 20:33:43 +00:00
}
);
};
//Validate Verification Token
$scope.validateVerifyToken = function() {
if($stateParams.token){
console.log($stateParams.token);
User.validateVerifyToken($stateParams.token).then(
function(response){
console.log('Success: '+response.message);
$scope.success = response.message;
$scope.isReset = true;
$scope.credentials = null;
},
function(error){
console.log('Error: '+error.message);
$scope.isReset = false;
$scope.error = error;
$scope.credentials = null;
}
);
}
}
}
]);