diff --git a/config.js b/config.js index 9952dca..f29a20f 100644 --- a/config.js +++ b/config.js @@ -10,6 +10,7 @@ angular.module('flashy', [ 'flashy.UserService', 'flashy.FlashcardDirective', 'flashy.ResetPasswordController', + 'flashy.VerifyEmailController', 'ngCookies']). config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', @@ -70,6 +71,10 @@ angular.module('flashy', [ url: '/resetpassword/{uid}/{token}', templateUrl: 'templates/resetpassword.html', controller: 'ResetPasswordController' + }). + state('verifyemail', { + url: '/verifyemail/{key}', + templateUrl: 'templates/verifyemail.html', + controller: 'VerifyEmailController' }); - }]); diff --git a/home.html b/home.html index 3b574b2..2c97787 100644 --- a/home.html +++ b/home.html @@ -36,6 +36,7 @@ <script src="scripts/RequestResetController.js"></script> <script src="scripts/ClassAddController.js"></script> <script src="scripts/ReviewController.js"></script> +<script src="scripts/VerifyEmailController.js"></script> <!-- Services --> <script src="scripts/UserService.js"></script> diff --git a/scripts/VerifyEmailController.js b/scripts/VerifyEmailController.js new file mode 100644 index 0000000..6e43ec8 --- /dev/null +++ b/scripts/VerifyEmailController.js @@ -0,0 +1,28 @@ +angular.module('flashy.VerifyEmailController', ['ui.router']) + + .controller('VerifyEmailController', ['$scope', '$state', '$http', '$timeout', + function($scope, $state, $http, $timeout) { + 'use strict'; + var url = document.location.href.split('/'); + var key = url[url.length-1]; + $scope.success = false; + $scope.error = false; + + $http.patch('/api/me', JSON.stringify({ + 'confirmation_key': key + })) + .success(function(data) { + $scope.success = true; + console.log("SUCCESS"); + console.log(data); + $timeout(function($state) { + $state.go('feed'); + }, 2000); + }) + .error(function(data, status, header, config) { + $scope.error = true; + console.log("ERROR"); + console.log(data); + }); + } + ]); diff --git a/templates/verifyemail.html b/templates/verifyemail.html new file mode 100644 index 0000000..ca9f35b --- /dev/null +++ b/templates/verifyemail.html @@ -0,0 +1,11 @@ +<div class="row" ng-show="success"> + <h1>Email verified!</h1> +</div> + +<div class="row" ng-show="error"> + <h1>Problem with email verification!</h1> +</div> + +<div class="row" ng-show="!success && !error"> + <p>hi, how did you get here?</p> +</div> \ No newline at end of file