Robin Thoni 8 роки тому
джерело
коміт
ef08d22f31

+ 1
- 0
public/app/controllers/login.controller.js Переглянути файл

@@ -11,6 +11,7 @@ angular.module('app')
11 11
             
12 12
             $scope.login = function()
13 13
             {
14
+                $scope.error = null;
14 15
                 if ($scope.user.Username == "" || $scope.user.Password == "") {
15 16
                     return;
16 17
                 }

+ 40
- 2
public/app/controllers/signup.controller.js Переглянути файл

@@ -1,4 +1,42 @@
1 1
 angular.module('app')
2
-    .controller('SignUpController', ['$scope', '$state', '$mdDialog',
3
-        function($scope, $state, $mdDialog) {
2
+    .controller('SignUpController', ['$scope', '$state', '$mdDialog', 'luticateAuthUsers',
3
+        function($scope, $state, $mdDialog, luticateAuthUsers) {
4
+            $scope.user = {
5
+                Username: "",
6
+                Passwords: {
7
+                    Password1: "",
8
+                    Password2: ""
9
+                },
10
+                Firstname: "",
11
+                Lastname: "",
12
+                Email: ""
13
+            };
14
+
15
+            $scope.error = null;
16
+
17
+            $scope.signUp = function () {
18
+                $scope.error = null;
19
+                if ($scope.user.Passwords.Password1 != $scope.user.Passwords.Password2) {
20
+                    $scope.error = {
21
+                        Data: "Passwords do not match"
22
+                    };
23
+                    return;
24
+                }
25
+                if ($scope.user.Username == "" || $scope.user.Firstname == ""
26
+                    || $scope.user.Lastname == "" || $scope.user.Email == "") {
27
+                    return;
28
+                }
29
+                luticateAuthUsers.add({
30
+                    username: $scope.user.Username,
31
+                    password: $scope.user.Passwords.Password1,
32
+                    firstname: $scope.user.Firstname,
33
+                    lastname: $scope.user.Lastname,
34
+                    email: $scope.user.Email
35
+                }).then(function(data)
36
+                {
37
+                    $state.go("login");
38
+                }, function (error) {
39
+                    $scope.error = error;
40
+                })
41
+            };
4 42
     }]);

+ 4
- 0
public/app/less/app.less Переглянути файл

@@ -35,4 +35,8 @@
35 35
 .error-message {
36 36
   color: red;
37 37
   font-weight: bold;
38
+}
39
+
40
+.strike {
41
+  text-decoration: line-through;
38 42
 }

+ 1
- 1
public/app/views/home.html Переглянути файл

@@ -1,5 +1,5 @@
1 1
 <div layout="column" layout-fill layout-align="top center">
2 2
     <p>
3
-        Welcome home
3
+        Welcome to <span class="strike">500px</span> 420px!
4 4
     </p>
5 5
 </div>

+ 48
- 3
public/app/views/signup.html Переглянути файл

@@ -1,5 +1,50 @@
1 1
 <div layout="column" layout-fill layout-align="top center">
2
-    <p>
3
-        Welcome home
4
-    </p>
2
+    <h1>Sign Up</h1>
3
+    <div class="col-xs-4">
4
+        <form ng-submit="signUp()">
5
+            <div>
6
+                <md-input-container class="col-xs-12">
7
+                    <label for="username">Username</label>
8
+                    <input name="username" id="username" type="text" ng-model="user.Username" required>
9
+                </md-input-container>
10
+            </div>
11
+            <div>
12
+                <md-input-container class="col-xs-12">
13
+                    <label for="firstname">First name</label>
14
+                    <input name="firstname" id="firstname" type="text" ng-model="user.Firstname" required>
15
+                </md-input-container>
16
+            </div>
17
+            <div>
18
+                <md-input-container class="col-xs-12">
19
+                    <label for="lastname">Last name</label>
20
+                    <input name="lastname" id="lastname" type="text" ng-model="user.Lastname" required>
21
+                </md-input-container>
22
+            </div>
23
+            <div>
24
+                <md-input-container class="col-xs-12">
25
+                    <label for="email">Email</label>
26
+                    <input name="email" id="email" type="text" ng-model="user.Email" required>
27
+                </md-input-container>
28
+            </div>
29
+            <div>
30
+                <md-input-container class="col-xs-12">
31
+                    <label for="password1">Password</label>
32
+                    <input name="password1" id="password1" type="password" ng-model="user.Passwords.Password1" required>
33
+                </md-input-container>
34
+            </div>
35
+            <div>
36
+                <md-input-container class="col-xs-12">
37
+                    <label for="password2">Password confirmation</label>
38
+                    <input name="password2" id="password2" type="password" ng-model="user.Passwords.Password2" required>
39
+                </md-input-container>
40
+            </div>
41
+            <div class="col-xs-10 col-xs-offset-1">
42
+                <md-button class="col-xs-12" type="submit">Sign Up!</md-button>
43
+            </div>
44
+        </form>
45
+        <div class="clearfix"></div>
46
+        <div ng-hide="error == null" class="error-message text-center">
47
+            {{ error.Data }}
48
+        </div>
49
+    </div>
5 50
 </div>

+ 4
- 1
public/app/views/toolbar.html Переглянути файл

@@ -5,7 +5,10 @@
5 5
         </md-button>
6 6
         <h2>Toolbar</h2>
7 7
         <span flex></span>
8
-        <span ng-hide="isLogged()"><a ui-sref="login">Login</a></span>
8
+        <div ng-hide="isLogged()">
9
+            <span><a ui-sref="signUp">Sign up</a></span> or
10
+            <span><a ui-sref="login">Login</a></span>
11
+        </div>
9 12
         <span ng-show="isLogged()"><a ui-sref="login">{{ getCurrentUser().Firstname }} {{ getCurrentUser().Lastname }}</a></span>
10 13
     </div>
11 14
 </md-toolbar>

Завантаження…
Відмінити
Зберегти