diff --git a/src/app/components/authentication/authentication.controller.js b/src/app/components/authentication/authentication.controller.js index 68e027a..45fd1f2 100644 --- a/src/app/components/authentication/authentication.controller.js +++ b/src/app/components/authentication/authentication.controller.js @@ -5,55 +5,21 @@ .controller('LoginCtrl', ['$scope', '$rootScope', '$state','$mdDialog','$log', 'AUTH_EVENTS', 'LoginService', 'toaster', loginCtrl]); function loginCtrl($scope, $rootScope, $state, $mdDialog,$log, AUTH_EVENTS, LoginService ,toaster) { - $scope.doLogin = function() { - $rootScope.auth = window.btoa($scope.loginData.email + ':' + $scope.loginData.password); - LoginService.doLogin().save($scope.loginData).$promise.then(function(result) { - console.log("result",result); - if(result){ - $rootScope.$broadcast(AUTH_EVENTS.updateUser); - LoginService.setUser(result); - /*if(result.role === 'admin'){ - $state.go("app.user"); - } else { - $state.go("app."); - } */ - $state.go("app.user"); - } - if (Notification.permission !== 'denied') { - Notification.requestPermission(function(permission) { - // If the user accepts, let's create a notification - if (permission === "granted") { - /*var notification = new Notification("Hello!");*/ - } - }); - } - }, - function error(error) { - console.log("ererrorror",error); - if(error){ - toaster.error("server error"); - } - }); - - } - $scope.signUp=function(){ - - LoginService.signUp().save($scope.signupData).$promise.then(function(result) { - console.log("result",result); - // toaster.success("signed up successfully") - $mdDialog.show( - $mdDialog.alert() - .clickOutsideToClose(true) - .title() - .textContent("Please check your email and click on the verification link before logging in.") - .ariaLabel('Alert') - .ok('ok') - ); - + $scope.data={} + $scope.create = function() { + LoginService.createForm().save($scope.data).$promise.then(function(result) { + if(result != null){ + toaster.success("form successfully created"); + // $state.go('app.awards'); + } + }, function error(error) { + if(error){ + toaster.error("Server error"); + } }); - - } - } + + } + })(); \ No newline at end of file diff --git a/src/app/components/authentication/authentication.service.js b/src/app/components/authentication/authentication.service.js index dce30ff..3a2c958 100644 --- a/src/app/components/authentication/authentication.service.js +++ b/src/app/components/authentication/authentication.service.js @@ -6,65 +6,12 @@ function LoginService($q, $http, $rootScope, $resource, BASE_URL, USER_ROLES) { - var authService = {}, - admin = '', - user = '', - role = '', - isAuthenticated = false; - - if (window.localStorage.getItem("loginStatus")) { - isAuthenticated = true; - $rootScope.userDetails = JSON.parse(localStorage.getItem("userDetails")); - role = $rootScope.userDetails.role.toUpperCase(); - } - - this.setUser = function (res) { - localStorage.setItem('loginStatus', true); - localStorage.setItem('userDetails', JSON.stringify(res)); - isAuthenticated = true; - $rootScope.userDetails = JSON.parse(localStorage.getItem("userDetails")); - role = $rootScope.userDetails.role.toUpperCase(); - } - - this.isAuthenticated = function () { - return isAuthenticated; - }; - - this.role = function () { - return role; - }; - - this.getUser = function () { - return JSON.parse(window.localStorage.getItem("userDetails")); - } - - this.isAuthorized = function (authorizedRoles) { - if (!angular.isArray(authorizedRoles)) { - authorizedRoles = [authorizedRoles]; - } - return (this.isAuthenticated() && authorizedRoles.indexOf(role) !== -1); + this.createForm = function(){ + return $resource(BASE_URL+'/userProfiles', + {}); + } - - this.signUp = function() { - return $resource(BASE_URL+'/users/signUp'); - } - - //Resource for REST APIs - this.doLogin = function() { - return $resource(BASE_URL+'/users/login'); - } - - this.logOut = function(){ - return $resource(BASE_URL+'/users/logout', - {access_token:$rootScope.userDetails.id}) - } - - this.deleteUser = function () { - isAuthenticated = false; - $rootScope.$loginStatus = false; - localStorage.clear(); - } - + } })(); \ No newline at end of file diff --git a/src/app/components/authentication/template/login.html b/src/app/components/authentication/template/login.html index 910e8a0..3126fb8 100644 --- a/src/app/components/authentication/template/login.html +++ b/src/app/components/authentication/template/login.html @@ -1,63 +1,39 @@ -

Startup Jalsa

- - + + - - Login + + Start Up Jalsa -
-
- - - + + + - - - - -
- Login -
-
-
-
-
- - - - - Sign Up - - -
- - - - + + + - - - + + + - - - + + place + - - - + + payment + -
- sign up -
-
+
+ submit +