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;
|
|
|
|
|
|
|
|
// Submit forgotten password account id
|
|
|
|
$scope.resendVerifyEmail = function() {
|
|
|
|
User.resendVerifyEmail($scope.email).then(
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|