mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 04:24:01 +00:00
added alternative bootstrap alert to frontends during the signup process
This commit is contained in:
@@ -31,10 +31,14 @@ class AuthController extends Controller
|
||||
public function sendVerification(Request $request){
|
||||
$credentials = $request->only('phone');
|
||||
$rules = [
|
||||
'phone' => 'required|digits:10|unique:users'
|
||||
'phone' => 'required|digits_between:10,11|unique:users'
|
||||
];
|
||||
$validator = Validator::make($credentials, $rules);
|
||||
|
||||
if($validator->fails()){
|
||||
return response()->json(['success'=> false, 'message'=> 'Incorrect length of mobile number or the number already exists. The minimum length should be 10.' ], 400);
|
||||
}
|
||||
|
||||
// create user if not exist
|
||||
$user = User::firstOrNew([
|
||||
'phone' => $request->phone
|
||||
@@ -59,7 +63,7 @@ class AuthController extends Controller
|
||||
//$message = "RM0.00 IZYIM: Verification code : ". $token;
|
||||
//$twilio = new Twilio(env('TWILIO_ACC'), env('TWILIO_TOKEN'), env('TWILIO_NUMBER'));
|
||||
//$twilio->message($request->phone, $message);
|
||||
return response()->json(['success'=> true, 'message'=> 'A verification code has been send to your mobile number.' ]);
|
||||
return response()->json(['success'=> true, 'message'=> 'A verification code has been send to your mobile number.' ], 200);
|
||||
|
||||
}
|
||||
|
||||
@@ -80,14 +84,14 @@ class AuthController extends Controller
|
||||
return response()->json([
|
||||
'success'=> true,
|
||||
'message'=> 'Account already verified.'
|
||||
]);
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
else{
|
||||
return response()->json([
|
||||
'success'=> false,
|
||||
'message'=> 'Please contact support.'
|
||||
]);
|
||||
], 400);
|
||||
}
|
||||
|
||||
// check and verify valid token
|
||||
@@ -110,7 +114,7 @@ class AuthController extends Controller
|
||||
'token_type' => 'bearer',
|
||||
'expires_in' => $expiration - time()]);
|
||||
}
|
||||
return response()->json(['success'=> false, 'error'=> "Verification code is invalid."]);
|
||||
return response()->json(['success'=> false, 'error'=> "Verification code is invalid."], 400);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +135,7 @@ class AuthController extends Controller
|
||||
|
||||
$validator = Validator::make($credentials, $rules);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['success'=> false, 'error'=> $validator->messages()]);
|
||||
return response()->json(['success'=> false, 'error'=> $validator->messages()], 400);
|
||||
}
|
||||
|
||||
$name = $request->name;
|
||||
@@ -151,9 +155,9 @@ class AuthController extends Controller
|
||||
$company = new Company;
|
||||
$company->user_id = $user->id;
|
||||
$company->save();
|
||||
|
||||
|
||||
return response()->json(['success'=> true, 'message'=> 'Profile updated.']);
|
||||
|
||||
return response()->json(['success'=> true, 'message'=> 'Profile updated.'], 200);
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +185,7 @@ class AuthController extends Controller
|
||||
try {
|
||||
// attempt to verify the credentials and create a token for the user
|
||||
if (! $token = JWTAuth::attempt($credentials)) {
|
||||
return response()->json(['success' => false, 'error' => 'We cant find an account with this credentials. Please make sure you entered the right information and you have verified your email address.'], 401);
|
||||
return response()->json(['success' => false, 'error' => 'Phone or password incorrect'], 401);
|
||||
}
|
||||
} catch (JWTException $e) {
|
||||
// something went wrong whilst attempting to encode the token
|
||||
|
||||
Reference in New Issue
Block a user