File tree 4 files changed +66
-35
lines changed
app/Http/Controllers/Auth 4 files changed +66
-35
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class LoginFormController {
19
19
. then ( ( response ) => {
20
20
this . $auth . setToken ( response . data ) ;
21
21
22
- //
22
+ this . ToastService . show ( 'Logged in successfully.' ) ;
23
23
} )
24
24
. catch ( this . failedLogin . bind ( this ) ) ;
25
25
}
Original file line number Diff line number Diff line change 1
- < div >
2
- < md-input-container >
3
- < label > Name</ label >
4
- < input type ="text " ng-model ="vm.name ">
5
- </ md-input-container >
6
- </ div >
1
+ < form ng-submit ="vm.register() ">
2
+ < div >
3
+ < md-input-container >
4
+ < label > Name</ label >
5
+ < input type ="text " ng-model ="vm.name ">
6
+ </ md-input-container >
7
+ </ div >
7
8
8
- < div >
9
- < md-input-container >
10
- < label > Email</ label >
11
- < input type ="email " ng-model ="vm.email ">
12
- </ md-input-container >
13
- </ div >
9
+ < div >
10
+ < md-input-container >
11
+ < label > Email</ label >
12
+ < input type ="email " ng-model ="vm.email ">
13
+ </ md-input-container >
14
+ </ div >
14
15
15
- < div >
16
- < md-input-container >
17
- < label > Password</ label >
18
- < input type ="password " ng-model ="vm.password ">
19
- </ md-input-container >
20
- </ div >
16
+ < div >
17
+ < md-input-container >
18
+ < label > Password</ label >
19
+ < input type ="password " ng-model ="vm.password ">
20
+ </ md-input-container >
21
+ </ div >
21
22
22
- < md-button type ="submit " class ="md-primary md-raised "> Register</ md-button >
23
+ < md-button type ="submit " class ="md-primary md-raised "> Register</ md-button >
24
+ </ form >
Original file line number Diff line number Diff line change 1
- class RegisterFormController {
2
- constructor ( ) {
3
- 'ngInject' ;
4
-
5
- this . name = '' ;
6
- this . email = '' ;
7
- this . password = '' ;
8
- }
1
+ class RegisterFormController {
2
+ constructor ( $auth , ToastService ) {
3
+ 'ngInject' ;
4
+
5
+ this . $auth = $auth ;
6
+ this . ToastService = ToastService ;
7
+
8
+ this . name = '' ;
9
+ this . email = '' ;
10
+ this . password = '' ;
11
+ }
12
+
13
+ register ( ) {
14
+ var user = {
15
+ name : this . name ,
16
+ email : this . email ,
17
+ password : this . password
18
+ } ;
19
+
20
+ this . $auth . signup ( user )
21
+ . then ( ( response ) => {
22
+ //remove this if you require email verification
23
+ this . $auth . setToken ( response . data ) ;
24
+
25
+ this . ToastService . show ( 'Successfully registered.' ) ;
26
+ } )
27
+ . catch ( this . failedRegistration . bind ( this ) ) ;
28
+ }
29
+
30
+
31
+
32
+ failedRegistration ( response ) {
33
+ if ( response . status === 422 ) {
34
+ for ( var error in response . data . errors ) {
35
+ return this . ToastService . error ( response . data . errors [ error ] [ 0 ] ) ;
36
+ }
37
+ }
38
+ this . ToastService . error ( response . statusText ) ;
39
+ }
9
40
}
10
41
11
42
export const RegisterFormComponent = {
12
- templateUrl : './views/app/components/register-form/register-form.component.html' ,
13
- controller : RegisterFormController ,
14
- controllerAs : 'vm' ,
15
- bindings : { }
43
+ templateUrl : './views/app/components/register-form/register-form.component.html' ,
44
+ controller : RegisterFormController ,
45
+ controllerAs : 'vm' ,
46
+ bindings : { }
16
47
}
17
-
18
-
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function postLogin(Request $request)
33
33
return response ()->success (compact ('user ' , 'token ' ));
34
34
}
35
35
36
- public function postRegister ()
36
+ public function postRegister (Request $ request )
37
37
{
38
38
$ this ->validate ($ request , [
39
39
'name ' => 'required|min:3 ' ,
You can’t perform that action at this time.
0 commit comments