mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 20:44:04 +00:00
Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/izyim-api into companyFrontend
# Conflicts: # public/company-profile.html
This commit is contained in:
@@ -7,6 +7,7 @@ use App\PasswordResets;
|
||||
use JWTAuth;
|
||||
use Auth;
|
||||
use App\Role;
|
||||
use App\Company;
|
||||
|
||||
use Aloha\Twilio\Twilio;
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
@@ -41,20 +42,20 @@ class AuthController extends Controller
|
||||
$user->save();
|
||||
|
||||
// create token if not exist, update if exist
|
||||
$token = mt_rand(0000,9999);
|
||||
$token = mt_rand(0000,9999);
|
||||
|
||||
// for testing
|
||||
// for testing
|
||||
if($request->phone == '0123456789'){
|
||||
$token = "1234";
|
||||
}
|
||||
|
||||
|
||||
$user_verification = $user->phoneVerification()->firstOrNew([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
$user_verification->token = $token;
|
||||
$user_verification->save();
|
||||
|
||||
// TODO: send token to phone
|
||||
// TODO: send token to phone
|
||||
//$message = "RM0.00 IZYIM: Verification code : ". $token;
|
||||
//$twilio = new Twilio(env('TWILIO_ACC'), env('TWILIO_TOKEN'), env('TWILIO_NUMBER'));
|
||||
//$twilio->message($request->phone, $message);
|
||||
@@ -99,7 +100,10 @@ class AuthController extends Controller
|
||||
if (!$userToken=JWTAuth::fromUser($check_user)) {
|
||||
return response()->json(['error' => 'invalid_credentials'], 401);
|
||||
}
|
||||
|
||||
|
||||
// TODO : Create company for user
|
||||
|
||||
|
||||
$expiration = JWTAuth::setToken($userToken)->getPayload()->get('exp');
|
||||
// all good so return the token
|
||||
return response()->json(['success' => true, 'token' => $userToken,
|
||||
@@ -129,7 +133,7 @@ class AuthController extends Controller
|
||||
if($validator->fails()) {
|
||||
return response()->json(['success'=> false, 'error'=> $validator->messages()]);
|
||||
}
|
||||
|
||||
|
||||
$name = $request->name;
|
||||
$password = $request->password;
|
||||
$role = $request->role;
|
||||
@@ -142,6 +146,12 @@ class AuthController extends Controller
|
||||
// attach role to user
|
||||
$user->attachRole($role);
|
||||
$user->update(['name' => $name, 'password' => Hash::make($password)]);
|
||||
|
||||
// TODO : create company for user
|
||||
$company = new Company;
|
||||
$company->user = $user;
|
||||
$company->save();
|
||||
|
||||
return response()->json(['success'=> true, 'message'=> 'Profile updated.']);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user