This commit is contained in:
Azfar Arsyad
2022-01-17 16:24:52 +08:00
parent 4dff8131e4
commit 3c20c03ab9
3 changed files with 49 additions and 2 deletions
@@ -19,13 +19,17 @@ class AuthController extends Controller
'username' => 'required|string|unique:users',
'nokp' => 'required|string|unique:users',
'password' => 'required|string|min:8',
'notelbimbit' => 'required|string',
'notelbimbit' => 'required|string|unique:users',
'register_agree' => 'required|integer'
]);
$errors = [
'success' => "error",
'message' => $validator->errors()
];
if ($validator->fails()) {
return response($validator->errors(), 201);
return response($errors, 201);
}
// Retrieve the validated input...
$fields = $validator->validated();
@@ -58,6 +62,7 @@ class AuthController extends Controller
$token = $user->createToken('myapptoken')->plainTextToken;
$response = [
'success' => "success",
'user' => $user,
'token' => $token
];