Commit 3459bcf483931a1b127cbeb55eec05091b80ca5d
1 parent
66ee5529fa
Exists in
master
modify new module
Showing
3 changed files
with
41 additions
and
152 deletions
Show diff stats
src/app/components/authentication/authentication.controller.js
... | ... | @@ -5,55 +5,21 @@ |
5 | 5 | .controller('LoginCtrl', ['$scope', '$rootScope', '$state','$mdDialog','$log', 'AUTH_EVENTS', 'LoginService', 'toaster', loginCtrl]); |
6 | 6 | |
7 | 7 | function loginCtrl($scope, $rootScope, $state, $mdDialog,$log, AUTH_EVENTS, LoginService ,toaster) { |
8 | - $scope.doLogin = function() { | |
9 | - $rootScope.auth = window.btoa($scope.loginData.email + ':' + $scope.loginData.password); | |
10 | - LoginService.doLogin().save($scope.loginData).$promise.then(function(result) { | |
11 | - console.log("result",result); | |
12 | - if(result){ | |
13 | - $rootScope.$broadcast(AUTH_EVENTS.updateUser); | |
14 | - LoginService.setUser(result); | |
15 | - /*if(result.role === 'admin'){ | |
16 | - $state.go("app.user"); | |
17 | - } else { | |
18 | - $state.go("app."); | |
19 | - } */ | |
20 | - $state.go("app.user"); | |
21 | - } | |
22 | - if (Notification.permission !== 'denied') { | |
23 | - Notification.requestPermission(function(permission) { | |
24 | - // If the user accepts, let's create a notification | |
25 | - if (permission === "granted") { | |
26 | - /*var notification = new Notification("Hello!");*/ | |
27 | - } | |
28 | - }); | |
29 | - } | |
30 | - }, | |
31 | - function error(error) { | |
32 | - console.log("ererrorror",error); | |
33 | - if(error){ | |
34 | - toaster.error("server error"); | |
35 | - } | |
36 | - }); | |
37 | - | |
38 | - } | |
39 | - $scope.signUp=function(){ | |
40 | - | |
41 | - LoginService.signUp().save($scope.signupData).$promise.then(function(result) { | |
42 | - console.log("result",result); | |
43 | - // toaster.success("signed up successfully") | |
44 | - $mdDialog.show( | |
45 | - $mdDialog.alert() | |
46 | - .clickOutsideToClose(true) | |
47 | - .title() | |
48 | - .textContent("Please check your email and click on the verification link before logging in.") | |
49 | - .ariaLabel('Alert') | |
50 | - .ok('ok') | |
51 | - ); | |
52 | - | |
8 | + $scope.data={} | |
9 | + $scope.create = function() { | |
10 | + LoginService.createForm().save($scope.data).$promise.then(function(result) { | |
11 | + if(result != null){ | |
12 | + toaster.success("form successfully created"); | |
13 | + // $state.go('app.awards'); | |
14 | + } | |
15 | + }, function error(error) { | |
16 | + if(error){ | |
17 | + toaster.error("Server error"); | |
18 | + } | |
53 | 19 | }); |
54 | 20 | |
55 | - | |
56 | - } | |
57 | - | |
58 | 21 | } |
22 | + | |
23 | + } | |
24 | + | |
59 | 25 | })(); |
60 | 26 | \ No newline at end of file | ... | ... |
src/app/components/authentication/authentication.service.js
... | ... | @@ -6,65 +6,12 @@ |
6 | 6 | |
7 | 7 | function LoginService($q, $http, $rootScope, $resource, BASE_URL, USER_ROLES) { |
8 | 8 | |
9 | - var authService = {}, | |
10 | - admin = '', | |
11 | - user = '', | |
12 | - role = '', | |
13 | - isAuthenticated = false; | |
14 | - | |
15 | - if (window.localStorage.getItem("loginStatus")) { | |
16 | - isAuthenticated = true; | |
17 | - $rootScope.userDetails = JSON.parse(localStorage.getItem("userDetails")); | |
18 | - role = $rootScope.userDetails.role.toUpperCase(); | |
19 | - } | |
20 | - | |
21 | - this.setUser = function (res) { | |
22 | - localStorage.setItem('loginStatus', true); | |
23 | - localStorage.setItem('userDetails', JSON.stringify(res)); | |
24 | - isAuthenticated = true; | |
25 | - $rootScope.userDetails = JSON.parse(localStorage.getItem("userDetails")); | |
26 | - role = $rootScope.userDetails.role.toUpperCase(); | |
27 | - } | |
28 | - | |
29 | - this.isAuthenticated = function () { | |
30 | - return isAuthenticated; | |
31 | - }; | |
32 | - | |
33 | - this.role = function () { | |
34 | - return role; | |
35 | - }; | |
36 | - | |
37 | - this.getUser = function () { | |
38 | - return JSON.parse(window.localStorage.getItem("userDetails")); | |
39 | - } | |
40 | - | |
41 | - this.isAuthorized = function (authorizedRoles) { | |
42 | - if (!angular.isArray(authorizedRoles)) { | |
43 | - authorizedRoles = [authorizedRoles]; | |
44 | - } | |
45 | - return (this.isAuthenticated() && authorizedRoles.indexOf(role) !== -1); | |
9 | + this.createForm = function(){ | |
10 | + return $resource(BASE_URL+'/userProfiles', | |
11 | + {}); | |
12 | + | |
46 | 13 | } |
47 | - | |
48 | - this.signUp = function() { | |
49 | - return $resource(BASE_URL+'/users/signUp'); | |
50 | - } | |
51 | - | |
52 | - //Resource for REST APIs | |
53 | - this.doLogin = function() { | |
54 | - return $resource(BASE_URL+'/users/login'); | |
55 | - } | |
56 | - | |
57 | - this.logOut = function(){ | |
58 | - return $resource(BASE_URL+'/users/logout', | |
59 | - {access_token:$rootScope.userDetails.id}) | |
60 | - } | |
61 | - | |
62 | - this.deleteUser = function () { | |
63 | - isAuthenticated = false; | |
64 | - $rootScope.$loginStatus = false; | |
65 | - localStorage.clear(); | |
66 | - } | |
67 | - | |
14 | + | |
68 | 15 | } |
69 | 16 | |
70 | 17 | })(); |
71 | 18 | \ No newline at end of file | ... | ... |
src/app/components/authentication/template/login.html
1 | -<h1 class="heading" style="text-align:center;">Startup Jalsa</h1> | |
2 | -<md-content class="md-padding" layout="row" layout-wrap layout-align="end center" style="width: 100%;background-color: #e0e0e0;"> | |
3 | - <md-card style="padding: 0px 20px;width:55%;margin-top: -180px;"> | |
1 | +<md-content class="md-padding" layout="row" layout-wrap layout-align="center start" style="width: 100%;background-color: #F1F1F1;"> | |
2 | + <md-card style="padding: 20px 40px;width: 70%;"> | |
4 | 3 | <md-card-title> |
5 | - <md-card-title-text style="text-align: center;color: dodgerblue;"> | |
6 | - <span class="md-headline">Login</span> | |
4 | + <md-card-title-text style="text-align: center;color: black"> | |
5 | + <span class="md-headline">Start Up Jalsa</span> | |
7 | 6 | </md-card-title-text> |
8 | 7 | </md-card-title> |
9 | - | |
10 | 8 | <form name="loginForm"> |
11 | - <div layout="column"> | |
12 | 9 | <md-input-container class="md-block md-icon-float"> |
13 | - <label>Email</label> | |
14 | - <md-icon md-svg-src="assets/images/ic_email_black_24px.svg" class="name"></md-icon> | |
15 | - <input ng-model="loginData.email"> | |
10 | + <label>Name</label> | |
11 | + <md-icon md-svg-src="assets/images/ic_person_black_24px.svg"></md-icon> | |
12 | + <input type="text" ng-model="data.name"> | |
16 | 13 | </md-input-container> |
17 | 14 | <md-input-container class="md-block md-icon-float"> |
18 | - <label>Password</label> | |
19 | - <md-icon md-svg-src="assets/images/ic_remove_red_eye_black_24px.svg" class="password"></md-icon> | |
20 | - <input type="password" ng-model="loginData.password"> | |
21 | - </md-input-container> | |
22 | - <section layout="column" layout-align="start"> | |
23 | - <md-button class="md-primary md-raised" ng-click="doLogin()">Login</md-button> | |
24 | - </section> | |
25 | - </div> | |
26 | - </form> | |
27 | -</md-card> | |
28 | -</md-content> | |
29 | -<md-content class="md-padding" layout="row" layout-wrap layout-align="start center" style="width: 100%;background-color:#e0e0e0;"> | |
30 | - <md-card style="padding: 0px 20px;width:60%;"> | |
31 | - <md-card-title> | |
32 | - <md-card-title-text style="text-align: center;color: dodgerblue;"> | |
33 | - <span class="md-headline">Sign Up</span> | |
34 | - </md-card-title-text> | |
35 | - </md-card-title> | |
36 | - <div layout="column"> | |
37 | - <md-input-container class="md-block md-icon-float"> | |
38 | - <label>Username</label> | |
39 | - <md-icon md-svg-src="assets/images/ic_person_black_24px.svg" class="name"></md-icon> | |
40 | - <input ng-model="signupData.username"> | |
15 | + <label>Email</label> | |
16 | + <md-icon md-svg-src="assets/images/ic_email_black_24px.svg" class="password"></md-icon> | |
17 | + <input type="text" ng-model="data.password"> | |
41 | 18 | </md-input-container> |
42 | 19 | <md-input-container class="md-block md-icon-float"> |
43 | - <label>Email</label> | |
44 | - <md-icon md-svg-src="assets/images/ic_email_black_24px.svg" class="email"></md-icon> | |
45 | - <input ng-model="signupData.email"> | |
20 | + <label>Mobile No.</label> | |
21 | + <md-icon md-svg-src="assets/images/ic_phone_black_24px.svg"></md-icon> | |
22 | + <input type="number" ng-model="data.phone"> | |
46 | 23 | </md-input-container> |
47 | 24 | <md-input-container class="md-block md-icon-float"> |
48 | - <label>Password</label> | |
49 | - <md-icon md-svg-src="assets/images/ic_remove_red_eye_black_24px.svg" class="password"></md-icon> | |
50 | - <input type="password" ng-model="signupData.password"> | |
25 | + <label>City</label> | |
26 | + <md-icon <i class="material-icons">place</i></md-icon> | |
27 | + <input type="text" ng-model="data.city"> | |
51 | 28 | </md-input-container> |
52 | 29 | <md-input-container class="md-block md-icon-float"> |
53 | - <label>Confirm Password</label> | |
54 | - <md-icon md-svg-src="assets/images/ic_remove_red_eye_black_24px.svg" class="confirmPassword"></md-icon> | |
55 | - <input type="password" ng-model="signupData.confirmPassword"> | |
30 | + <label>Monthly Income</label> | |
31 | + <md-icon <i class="material-icons">payment</i></md-icon> | |
32 | + <input type="text" ng-model="data.monthlyIncome"> | |
56 | 33 | </md-input-container> |
57 | - <section layout="column" layout-align="start"> | |
58 | - <md-button class="md-primary md-raised" ng-click="signUp()">sign up</md-button> | |
59 | - </section> | |
60 | - </div> | |
34 | + <div layout="row" layout-align="center center"> | |
35 | + <md-button class="md-raised md-primary" id="createPass" ng-disabled="loginForm.$invalid" ng-click="create()">submit</md-button> | |
36 | + </div> | |
61 | 37 | </form> |
62 | 38 | </md-card> |
63 | 39 | </md-content> | ... | ... |