parent
d6264b4064
commit
0b6e9b5ace
|
@ -11,33 +11,36 @@ use Illuminate\Support\Facades\Auth;
|
|||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class RegisteredUserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the registration view.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('auth.register');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming registration request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function validateHandle(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'littlelink_name' => 'required|string|max:50|unique:users',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['valid' => false]);
|
||||
}
|
||||
|
||||
return response()->json(['valid' => true]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'littlelink_name' => 'required|string|max:50|unique:users',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|confirmed|min:8',
|
||||
'password' => 'required|string|min:8',
|
||||
]);
|
||||
|
||||
$name = $request->input('name');
|
||||
|
@ -48,23 +51,13 @@ class RegisteredUserController extends Controller
|
|||
$block = 'no';
|
||||
}
|
||||
|
||||
if(DB::table('users')->where('littlelink_name', $request->name)->exists())
|
||||
{
|
||||
Auth::login($user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'littlelink_name' => $request->littlelink_name,
|
||||
'password' => Hash::make($request->password),
|
||||
'role' => 'user',
|
||||
]));
|
||||
} else {
|
||||
Auth::login($user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'littlelink_name' => $request->name,
|
||||
'password' => Hash::make($request->password),
|
||||
'role' => 'user',
|
||||
]));
|
||||
}
|
||||
|
||||
$user->block = $block;
|
||||
$user->save();
|
||||
|
|
|
@ -18,7 +18,7 @@ foreach($pages as $page)
|
|||
<!-- Validation Errors -->
|
||||
<x-auth-validation-errors class="mb-4" :errors="$errors" />
|
||||
|
||||
<div style="max-width:480px" class="container mt-5 w-100">
|
||||
<div class="container mt-5 w-100">
|
||||
<div class="card p-5">
|
||||
<a href="{{ url('') }}" class="d-flex align-items-center mb-3">
|
||||
<!--Logo start-->
|
||||
|
@ -53,6 +53,16 @@ foreach($pages as $page)
|
|||
<input type="text" class="form-control" id="name" name="name" aria-describedby="name" placeholder=" " :value="old('name')" required autofocus >
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label for="littlelink_name" class="form-label">{{__('messages.Page URL')}}</label>
|
||||
<div class="input-group mb-3 has-validation">
|
||||
<span class="input-group-text" id="basic-addon3">{{str_replace(['http://', 'https://'], '', url(''))}}/@</span>
|
||||
<input type="littlelink_name" class="form-control" id="littlelink_name" name="littlelink_name" aria-describedby="littlelink_name" placeholder=" " :value="old('littlelink_name')" required autofocus >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@include('auth.url-validation')
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label for="email" class="form-label">{{__('messages.Email')}}</label>
|
||||
|
@ -65,12 +75,6 @@ foreach($pages as $page)
|
|||
<input type="password" class="form-control" id="password" aria-describedby="password" placeholder=" " name="password" required autocomplete="new-password" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label for="password_confirmation" class="form-label">{{__('messages.Confirm Password')}}</label>
|
||||
<input type="password" class="form-control" id="password_confirmation" aria-describedby="password_confirmation" placeholder=" " name="password_confirmation" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12 d-flex justify-content-between">
|
||||
<div class="form-check mb-3">
|
||||
<input type="checkbox" class="form-check-input" name="remember" id="remember_me">
|
||||
|
@ -79,7 +83,7 @@ foreach($pages as $page)
|
|||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="submit" class="btn btn-primary">{{__('messages.Sign Up')}}</button>
|
||||
<button id="submit-btn" type="submit" class="btn btn-primary">{{__('messages.Sign Up')}}</button>
|
||||
</div>
|
||||
@if(env('ENABLE_SOCIAL_LOGIN') == 'true')
|
||||
<p class="text-center my-3">{{__('messages.or sign in with other accounts?')}}</p>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<script>{!! file_get_contents(base_path("assets/js/jquery.min.js")) !!}</script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
var submitBtn = $('#submit-btn');
|
||||
|
||||
$('#littlelink_name').on('keyup', function () {
|
||||
var littlelinkName = $(this).val();
|
||||
|
||||
if (littlelinkName.trim() !== '') {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '{{url("/validate-handle")}}',
|
||||
data: {
|
||||
'_token': '{{ csrf_token() }}',
|
||||
'littlelink_name': littlelinkName
|
||||
},
|
||||
success: function (data) {
|
||||
$('#littlelink_name').removeClass('is-valid is-invalid');
|
||||
$('#username-error').remove();
|
||||
|
||||
if (data.valid) {
|
||||
$('#littlelink_name').addClass('is-valid');
|
||||
submitBtn.prop('disabled', false);
|
||||
} else {
|
||||
$('#littlelink_name').addClass('is-invalid');
|
||||
$('<div id="username-error" class="invalid-feedback">That username is already taken</div>').insertAfter('#littlelink_name');
|
||||
submitBtn.prop('disabled', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#littlelink_name').removeClass('is-valid is-invalid');
|
||||
$('#username-error').remove();
|
||||
submitBtn.prop('disabled', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
Loading…
Reference in New Issue