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
|
||||
|
||||
@@ -15,9 +15,30 @@ class CompanyController extends Controller
|
||||
$company = Company::where("user_id", Auth::user()->id)->first();
|
||||
if (!$company)
|
||||
{
|
||||
return response()->json(['message'=>'company not found'], 404);
|
||||
return response()->json(['success'=> false, 'message'=>'Company not found'], 404);
|
||||
}
|
||||
|
||||
$rules = [
|
||||
'company_name' => 'required',
|
||||
'registration_no' => 'required',
|
||||
'tax_no' => 'required',
|
||||
'tax_no' => 'required',
|
||||
'tel_no' => 'required',
|
||||
'fax' => 'required',
|
||||
'address' => 'required',
|
||||
'city' => 'required',
|
||||
'postcode' => 'required',
|
||||
'state' => 'required',
|
||||
'country' => 'required',
|
||||
'contact_person' => 'required'
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['success'=> false, 'error'=> 'All the fields are required'], 400);
|
||||
//return response()->json(['success'=> false, 'error'=> $validator->messages()], 400);
|
||||
}
|
||||
|
||||
$company->company_name=$request->input('company_name');
|
||||
$company->registration_no=$request->input('registration_no');
|
||||
$company->tax_no=$request->input('tax_no');
|
||||
@@ -31,7 +52,7 @@ class CompanyController extends Controller
|
||||
$company->contact_person=$request->input('contact_person');
|
||||
|
||||
$company->save();
|
||||
return response()->json(['company'=>$company],200);
|
||||
return response()->json(['success'=> true, 'message'=>'Company created successfully'],200);
|
||||
}
|
||||
|
||||
public function companyProfile(Request $request)
|
||||
@@ -39,7 +60,7 @@ class CompanyController extends Controller
|
||||
$company = Company::where("user_id", Auth::user()->id)->first();
|
||||
if (!$company)
|
||||
{
|
||||
return response()->json(['message'=>'company for company_prof not found'],200);
|
||||
return response()->json(['success'=> false, 'error'=>'Company not found'], 404);
|
||||
}
|
||||
//validaating file types
|
||||
$validator = Validator::make($request->all(), [
|
||||
@@ -47,7 +68,7 @@ class CompanyController extends Controller
|
||||
]);
|
||||
if($validator->fails())
|
||||
{
|
||||
return response()->json(['message'=>'Incorrect format'],200);
|
||||
return response()->json(['success'=> false, 'error'=>'Incorrect format'], 400);
|
||||
}
|
||||
|
||||
if($file = $request->file('company_profile')) //company profile picture
|
||||
@@ -65,7 +86,7 @@ class CompanyController extends Controller
|
||||
$company->company_profile = $unique_name. '.' .$ext; //update database
|
||||
} //end if
|
||||
$company->save();
|
||||
return response()->json(['company'=>$company],200);
|
||||
return response()->json(['success'=> true, 'message'=>'Company profile picture uploaded successfully'],200);
|
||||
}//end of companyProfile()
|
||||
|
||||
public function regCert(Request $request)
|
||||
@@ -73,7 +94,7 @@ class CompanyController extends Controller
|
||||
$company = Company::where("user_id", Auth::user()->id)->first();
|
||||
if (!$company)
|
||||
{
|
||||
return response()->json(['message'=>'Company not found'], 404);
|
||||
return response()->json(['success'=> false, 'error'=>'Company not found'], 404);
|
||||
}
|
||||
|
||||
//validating file types
|
||||
@@ -81,7 +102,7 @@ class CompanyController extends Controller
|
||||
'reg_cert' => 'mimes:jpg,jpeg,bmp,png,gif,svg,pdf'
|
||||
]);
|
||||
if($validator->fails()){
|
||||
return response()->json(['message'=>'Incorrect format'],200);
|
||||
return response()->json(['success'=> false, 'error'=>'Incorrect format'], 400);
|
||||
}
|
||||
|
||||
if($request->hasFile('reg_cert')) //Registration Certificate upload
|
||||
@@ -99,7 +120,7 @@ class CompanyController extends Controller
|
||||
$company->reg_cert = $unique_name. '.' .$ext; //this updates database
|
||||
}//end if
|
||||
$company->save();
|
||||
return response()->json(['company'=>$company],200);
|
||||
return response()->json(['success'=> true, 'message'=>'Registration Certificate uploaded successfully'], 200);
|
||||
}//end regCert()
|
||||
|
||||
}//end of class
|
||||
Generated
+13702
File diff suppressed because it is too large
Load Diff
+34
-18
@@ -3,6 +3,7 @@
|
||||
<title>AzureUI - Term</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito:300,400,600,700,900" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/global.style.css" />
|
||||
@@ -66,7 +67,7 @@
|
||||
<label class="update-btn fix">
|
||||
<div class="form-row txt-center">
|
||||
<input id="reg_cert" type="file" />
|
||||
<div class="form-divider"></div>
|
||||
<div class="form-divider"></div>
|
||||
<a href="#" id="regCert" style="width:50%; margin-left:25%;" class="button block green">Upload</a>
|
||||
</div>
|
||||
</label>
|
||||
@@ -74,15 +75,21 @@
|
||||
|
||||
</form>
|
||||
|
||||
<br>
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<div class="form-label-divider">
|
||||
<span class="label-span">Company Information</span>
|
||||
</div>
|
||||
<div class="alert alert-danger" id="alert" role="alert" style="display: none"></div>
|
||||
<div class="alert alert-success" id="alert1" role="alert1" style="display: none"></div>
|
||||
|
||||
<div class="form-divider"></div>
|
||||
<br>
|
||||
|
||||
<form>
|
||||
<div class="form-label-divider">
|
||||
<span class="label-span">Company Information</span>
|
||||
</div>
|
||||
|
||||
<div class="form-divider"></div>
|
||||
<div class="alert alert-danger" id="alert2" role="alert2" style="display: none"></div>
|
||||
|
||||
<form>
|
||||
<div class="form-row-group">
|
||||
<div class="form-row no-padding">
|
||||
<input id="company-name" type="text" class="form-element" placeholder="Company Name" required />
|
||||
@@ -122,8 +129,8 @@
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<div class="form-row txt-center">
|
||||
<a href="#" id="companyDetails" style="width:50%; margin-left:25%;" class="button block green">Submit</a>
|
||||
</div>
|
||||
<a href="#" id="companyDetails" style="width:50%; margin-left:25%;" class="button block green">Submit</a>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
@@ -131,6 +138,8 @@
|
||||
<!-- Main Content End Here -->
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#regCert').click(function() {
|
||||
@@ -142,17 +151,21 @@
|
||||
url: "api/company/reg_cert/",
|
||||
headers: {"Authorization": 'Bearer' + localStorage.getItem('token')},
|
||||
data:fd,
|
||||
// {
|
||||
// file:new FormData(this),
|
||||
// },
|
||||
contentType: false,
|
||||
cache: false,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
alert("Upload successful");
|
||||
document.getElementById("alert").style.display = "none";
|
||||
console.log(data.message);
|
||||
$('#alert1').html(data.message);
|
||||
$('#alert1').show();
|
||||
},
|
||||
error: function() {
|
||||
alert("Login Failed");}
|
||||
error: function(data) {
|
||||
console.log(data);
|
||||
document.getElementById("alert1").style.display = "none";
|
||||
$('#alert').html(data.responseJSON.error);
|
||||
$('#alert').show();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
@@ -175,11 +188,14 @@
|
||||
contact_person: $('#contact-person').val()
|
||||
},
|
||||
success: function(data) {
|
||||
alert("success");
|
||||
//alert("success");
|
||||
document.location.href="home.html";
|
||||
},
|
||||
error: function() {
|
||||
alert("Login Failed");}
|
||||
error: function(data) {
|
||||
//console.log(data);
|
||||
$('#alert2').html(data.responseJSON.error);
|
||||
$('#alert2').show();
|
||||
}
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
+11
-3
@@ -4,6 +4,7 @@
|
||||
<title>AzureUI - SIGNIN</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito:300,400,600,700,900" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/global.style.css">
|
||||
@@ -21,6 +22,9 @@
|
||||
<section class="container">
|
||||
<form>
|
||||
@csrf
|
||||
<div class="alert alert-danger" role="alert" style="display: none">
|
||||
|
||||
</div>
|
||||
<div class="form-row-group with-icons">
|
||||
<div class="form-row no-padding">
|
||||
<div style="position:absolute; top: 10px;">
|
||||
@@ -36,6 +40,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<div class="form-row txt-center">
|
||||
@@ -60,6 +65,8 @@
|
||||
</div>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#login').click(function() {
|
||||
@@ -73,10 +80,11 @@
|
||||
success: function(data) {
|
||||
localStorage.token = data.data.token;
|
||||
document.location.href="home.html";
|
||||
alert('Got a token from the server! Token: ' + data.data.token);
|
||||
},
|
||||
error: function() {
|
||||
alert("Login Failed");}
|
||||
error: function(data) {
|
||||
$('.alert').html(data.responseJSON.error);
|
||||
$('.alert').show();
|
||||
}
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<title>AzureUI - Term</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito:300,400,600,700,900" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/global.style.css" />
|
||||
@@ -42,6 +43,10 @@
|
||||
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<div class="alert alert-danger" id="alert" role="alert" style="display: none"></div>
|
||||
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<div class="form-row-group with-icons-no-padding">
|
||||
<div class="form-row no-padding">
|
||||
<div class="form-element-title">
|
||||
@@ -95,6 +100,8 @@
|
||||
<script src="js/global.script.js"></script>
|
||||
<!-- Require For All Pages -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#pers-info').click(function() {
|
||||
@@ -111,9 +118,18 @@
|
||||
success: function(data) {
|
||||
document.location.href="company-profile.html";
|
||||
},
|
||||
error: function() {
|
||||
alert("Failed");}
|
||||
})
|
||||
error: function(data) {
|
||||
var errors = $.parseJSON(data.responseText);
|
||||
//console.log(errors.error);
|
||||
if (errors != null){
|
||||
for (var i in errors.error) {
|
||||
//console.log(errors.error[i][0]);
|
||||
$('.alert').append(errors.error[i][0] + "<br/>");
|
||||
}
|
||||
}
|
||||
$('.alert').show();
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<title>AzureUI - Term</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito:300,400,600,700,900" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/global.style.css" />
|
||||
@@ -24,6 +25,9 @@
|
||||
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<!--Error Alert-->
|
||||
<div class="alert alert-danger" role="alert" style="display: none"></div>
|
||||
|
||||
<!-- Here Lies Main Start Here -->
|
||||
<main>
|
||||
<section class="container">
|
||||
@@ -52,6 +56,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript">
|
||||
function readCookie(name) {
|
||||
var nameEQ = encodeURIComponent(name) + "=";
|
||||
@@ -82,12 +88,15 @@
|
||||
document.location.href="profile-first-setup.html";
|
||||
}
|
||||
else{
|
||||
console.log('wrong code');
|
||||
//console.log('wrong code');
|
||||
$('.alert').html(data.success.message);
|
||||
$('.alert').show();
|
||||
}
|
||||
//
|
||||
},
|
||||
error: function() {
|
||||
alert("Failed");}
|
||||
error: function(data) {
|
||||
$('.alert').html(data.responseJSON.error);
|
||||
$('.alert').show();}
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<title>AzureUI - Term</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito:300,400,600,700,900" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/global.style.css" />
|
||||
@@ -50,6 +51,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-divider"></div>
|
||||
|
||||
<!--Error Alert-->
|
||||
<div class="alert alert-danger" role="alert" style="display: none"></div>
|
||||
|
||||
<!-- AzFooter Start Here-->
|
||||
<div class="azfooter">
|
||||
<div class="azfmain-button">
|
||||
@@ -71,6 +77,8 @@
|
||||
</div>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript">
|
||||
function createCookie(name, value, days) {
|
||||
var expires;
|
||||
@@ -97,8 +105,10 @@
|
||||
document.location.href="verify-code-number.html";
|
||||
},
|
||||
Cookies:createCookie('phone', mobile, 60),
|
||||
error: function() {
|
||||
alert("Failed");}
|
||||
error: function(data) {
|
||||
$('.alert').html(data.responseJSON.message);
|
||||
$('.alert').show();
|
||||
}
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user