Skip to content

Commit a60e3eb

Browse files
committed
Repair registration
1 parent 2713820 commit a60e3eb

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

coreui/src/views/pages/Login.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<div>
3838
<h2>Sign up</h2>
3939
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
40-
<b-button variant="primary" class="active mt-3">Register Now!</b-button>
40+
<b-button variant="primary" class="active mt-3" @click="goRegister">Register Now!</b-button>
4141
</div>
4242
</b-card-body>
4343
</b-card>
@@ -85,8 +85,11 @@ import axios from "axios";
8585
console.log(error);
8686
});
8787
88+
},
89+
goRegister(){
90+
this.$router.push({ path: 'register' });
8891
}
89-
}
92+
},
9093
}
9194
9295

coreui/src/views/pages/Register.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@
9595
self.password_confirmation = '';
9696
9797
console.log(response);
98-
99-
//self.$router.push('Login');
98+
self.$router.push('Login');
10099
})
101100
.catch(function (error) {
102101
console.log(error);

laravel/app/Http/Controllers/AuthController.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,32 @@ public function __construct()
1818
{
1919
$this->middleware('auth:api', ['except' => ['login', 'register']]);
2020
}
21-
21+
22+
/**
23+
* Register new user.
24+
*
25+
* @return \Illuminate\Http\JsonResponse
26+
*/
27+
public function register(Request $request){
28+
$validate = Validator::make($request->all(), [
29+
'name' => 'required',
30+
'email' => 'required|email|unique:users',
31+
'password' => 'required|min:4|confirmed',
32+
]);
33+
if ($validate->fails()){
34+
return response()->json([
35+
'status' => 'error',
36+
'errors' => $validate->errors()
37+
], 422);
38+
}
39+
$user = new User;
40+
$user->name = $request->name;
41+
$user->email = $request->email;
42+
$user->password = bcrypt($request->password);
43+
$user->status = 1;
44+
$user->save();
45+
return response()->json(['status' => 'success'], 200);
46+
}
2247

2348
/**
2449
* Get a JWT via given credentials.

laravel/app/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function getJWTCustomClaims()
3939
* @var array
4040
*/
4141
protected $fillable = [
42-
'name', 'email', 'password',
42+
'name', 'email', 'password', 'status'
4343
];
4444

4545
/**

0 commit comments

Comments
 (0)