UNPKG

gaf-mobile

Version:

GAF mobile Web site

44 lines (38 loc) 1.34 kB
'use strict'; angular.module('gafMobileApp') .controller('ResetPasswordCtrl', function ($location, Auth, Analytics) { var _this = this; // Default login form state _this.state = { success: false }; // Store the errors _this.error = {}; // Reset password _this.resetPassword = function(email) { // Clear any previous errors _this.error = {}; return Auth.resetPassword(email) .then(function() { Analytics.trackAction('user', 'reset password', 'SUCCESS'); _this.state.success = true; }) .catch(function(error) { if (error.code === 'UNKNOWN_EMAIL') { Analytics.trackAction('user', 'reset password', error.code); _this.error.unknownEmail = true; } else if (error.code === 'INVALID_EMAIL') { Analytics.trackAction('user', 'reset password', error.code); _this.error.invalidEmail = true; } else if (error.code === 'ACCESS_DENIED') { Analytics.trackAction('user', 'reset password', error.code); _this.error.accessDenied = true; } else { Analytics.trackError('user', 'reset password', error.code, error.data); _this.error.internalError = error.code; } }); }; });