File tree 8 files changed +50
-34
lines changed 8 files changed +50
-34
lines changed Original file line number Diff line number Diff line change 1
- < div >
2
- < md-input-container class ="LoginForm-inputContainer ">
3
- < label > Email</ label >
4
- < input type ="email " ng-model ="vm.email ">
5
- </ md-input-container >
6
- </ div >
1
+ < form ng-submit ="vm.login() ">
2
+ < div >
3
+ < md-input-container class ="LoginForm-inputContainer ">
4
+ < label > Email</ label >
5
+ < input type ="email " ng-model ="vm.email ">
6
+ </ md-input-container >
7
+ </ div >
7
8
8
- < div >
9
- < md-input-container class ="LoginForm-inputContainer ">
10
- < label > Password</ label >
11
- < input type ="password " ng-model ="vm.password ">
12
- </ md-input-container >
13
- </ div >
9
+ < div >
10
+ < md-input-container class ="LoginForm-inputContainer ">
11
+ < label > Password</ label >
12
+ < input type ="password " ng-model ="vm.password ">
13
+ </ md-input-container >
14
+ </ div >
14
15
15
- < md-button type ="submit " class ="LoginForm-submit md-primary md-raised "> Login</ md-button >
16
+ < md-button type ="submit " class ="LoginForm-submit md-primary md-raised "> Login</ md-button >
17
+ </ form >
Original file line number Diff line number Diff line change 1
- class LoginFormController {
2
- constructor ( ) {
3
- 'ngInject' ;
1
+ class LoginFormController {
2
+ constructor ( $auth ) {
3
+ 'ngInject' ;
4
4
5
- this . email = '' ;
6
- this . password = '' ;
7
- }
5
+ this . $auth = $auth ;
6
+
7
+ this . email = '' ;
8
+ this . password = '' ;
9
+ }
10
+
11
+ login ( ) {
12
+ var user = {
13
+ email : this . email ,
14
+ password : this . password
15
+ } ;
16
+
17
+ this . $auth . login ( user )
18
+ . then ( ( response ) => {
19
+ this . $auth . setToken ( response . data . data . token ) ;
20
+ } ) ;
21
+ }
8
22
}
9
23
10
24
export const LoginFormComponent = {
11
- templateUrl : './views/app/components/login-form/login-form.component.html' ,
12
- controller : LoginFormController ,
13
- controllerAs : 'vm' ,
14
- bindings : { }
25
+ templateUrl : './views/app/components/login-form/login-form.component.html' ,
26
+ controller : LoginFormController ,
27
+ controllerAs : 'vm' ,
28
+ bindings : { }
15
29
}
16
-
17
-
Original file line number Diff line number Diff line change 2
2
< div layout ="row ">
3
3
< div flex ="90 " flex-offset ="5 " class ="DemoHeader-container ">
4
4
< div layout ="row " layout-align ="space-between ">
5
- < img src ="img/icons/logo.svg " class ="DemoHeader-logo "/>
5
+ < img src ="img/icons/logo.svg " ui-sref =" app.landing " class ="DemoHeader-logo "/>
6
6
< div layout ="row " layout-align ="center stretch " hide-xs >
7
7
< a class ="DemoHeader-link md-subhead " href ="https://laravel-angular.readme.io " target ="_blank "> Docs</ a >
8
8
< a class ="DemoHeader-link md-subhead " href ="https://www.youtube.com/watch?list=PLIiQ4B5FSupiQYLX6kERPV0OhMC7tTbBE&v=_ZWV9KBK2N8 " target ="_blank "> Screencasts</ a >
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export function SatellizerConfig($authProvider) {
5
5
return true ;
6
6
}
7
7
8
- $authProvider . loginUrl = '/auth/login' ;
9
- $authProvider . signupUrl = '/auth/signup ' ;
8
+ $authProvider . loginUrl = '/api/ auth/login' ;
9
+ $authProvider . signupUrl = '/api/ auth/register ' ;
10
10
11
11
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace App \Http \Controllers \Auth ;
4
4
5
+ use Auth ;
5
6
use JWTAuth ;
6
7
use App \User ;
8
+ use Illuminate \Http \Request ;
7
9
use App \Http \Controllers \Controller ;
8
10
9
11
class AuthController extends Controller
@@ -15,13 +17,15 @@ public function postLogin(Request $request)
15
17
try {
16
18
// verify the credentials and create a token for the user
17
19
if (! $ token = JWTAuth::attempt ($ credentials )) {
18
- return response ()->error ('Invalid credentials ' , Response:: HTTP_UNAUTHORIZED );
20
+ return response ()->error ('Invalid credentials ' , 401 );
19
21
}
20
22
} catch (\JWTException $ e ) {
21
- return response ()->error ('Could not create token ' , Response:: HTTP_INTERNAL_SERVER_ERROR );
23
+ return response ()->error ('Could not create token ' , 500 );
22
24
}
23
25
24
- return response ()->success (compact ('token ' ));
26
+ $ user = Auth::user ();
27
+
28
+ return response ()->success (compact ('user ' , 'token ' ));
25
29
}
26
30
27
31
public function postRegister ()
Original file line number Diff line number Diff line change 39
39
//protected routes with JWT (must be logged in to access any of these routes)
40
40
$ api ->group (['middleware ' => 'api.auth ' ], function ($ api ) {
41
41
42
- $ api ->get ('sample/protected ' , 'LoginController@protectedData ' );
43
-
44
42
});
Original file line number Diff line number Diff line change 55
55
'mysql ' => [
56
56
'driver ' => 'mysql ' ,
57
57
'host ' => env ('DB_HOST ' , 'localhost ' ),
58
+ 'port ' => env ('DB_PORT ' , '3306 ' ),
58
59
'database ' => env ('DB_DATABASE ' , 'forge ' ),
59
60
'username ' => env ('DB_USERNAME ' , 'forge ' ),
60
61
'password ' => env ('DB_PASSWORD ' , '' ),
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ public function up()
17
17
$ table ->string ('name ' );
18
18
$ table ->string ('email ' )->unique ();
19
19
$ table ->string ('password ' , 60 );
20
- $ table ->rememberToken ();
21
20
$ table ->timestamps ();
22
21
});
23
22
}
You can’t perform that action at this time.
0 commit comments