mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-02-03 18:30:47 +00:00
Refactor based on @jippi review
This commit is contained in:
parent
509a50b8e0
commit
cc78dfc650
4 changed files with 13 additions and 13 deletions
|
@ -19,7 +19,7 @@ class AppRegisterController extends Controller
|
|||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
abort_unless(config('auth.iar') == true, 404);
|
||||
abort_unless(config('auth.in_app_registration'), 404);
|
||||
$open = (bool) config_cache('pixelfed.open_registration');
|
||||
if (! $open || $request->user()) {
|
||||
return redirect('/');
|
||||
|
@ -30,7 +30,7 @@ class AppRegisterController extends Controller
|
|||
|
||||
public function store(Request $request)
|
||||
{
|
||||
abort_unless(config('auth.iar') == true, 404);
|
||||
abort_unless(config('auth.in_app_registration'), 404);
|
||||
$open = (bool) config_cache('pixelfed.open_registration');
|
||||
if (! $open || $request->user()) {
|
||||
return redirect('/');
|
||||
|
@ -46,9 +46,11 @@ class AppRegisterController extends Controller
|
|||
|
||||
$this->validate($request, $rules);
|
||||
|
||||
$email = $request->input('email');
|
||||
$email = strtolower($request->input('email'));
|
||||
$code = str_pad(random_int(0, 999999), 6, '0', STR_PAD_LEFT);
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$exists = AppRegister::whereEmail($email)->where('created_at', '>', now()->subHours(24))->count();
|
||||
|
||||
if ($exists && $exists > 3) {
|
||||
|
@ -56,12 +58,10 @@ class AppRegisterController extends Controller
|
|||
'status' => 'error',
|
||||
'message' => 'Too many attempts, please try again later.',
|
||||
]);
|
||||
|
||||
DB::rollBack();
|
||||
return redirect()->away("pixelfed://verifyEmail?{$errorParams}");
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$registration = AppRegister::create([
|
||||
'email' => $email,
|
||||
'verify_code' => $code,
|
||||
|
@ -93,7 +93,7 @@ class AppRegisterController extends Controller
|
|||
|
||||
public function verifyCode(Request $request)
|
||||
{
|
||||
abort_unless(config('auth.iar') == true, 404);
|
||||
abort_unless(config('auth.in_app_registration'), 404);
|
||||
$open = (bool) config_cache('pixelfed.open_registration');
|
||||
if (! $open || $request->user()) {
|
||||
return redirect('/');
|
||||
|
@ -104,7 +104,7 @@ class AppRegisterController extends Controller
|
|||
'verify_code' => ['required', 'digits:6', 'numeric'],
|
||||
]);
|
||||
|
||||
$email = $request->input('email');
|
||||
$email = strtolower($request->input('email'));
|
||||
$code = $request->input('verify_code');
|
||||
|
||||
$exists = AppRegister::whereEmail($email)
|
||||
|
@ -119,7 +119,7 @@ class AppRegisterController extends Controller
|
|||
|
||||
public function onboarding(Request $request)
|
||||
{
|
||||
abort_unless(config('auth.iar') == true, 404);
|
||||
abort_unless(config('auth.in_app_registration'), 404);
|
||||
$open = (bool) config_cache('pixelfed.open_registration');
|
||||
if (! $open || $request->user()) {
|
||||
return redirect('/');
|
||||
|
@ -133,7 +133,7 @@ class AppRegisterController extends Controller
|
|||
'password' => 'required|string|min:'.config('pixelfed.min_password_length'),
|
||||
]);
|
||||
|
||||
$email = $request->input('email');
|
||||
$email = strtolower($request->input('email'));
|
||||
$code = $request->input('verify_code');
|
||||
$username = $request->input('username');
|
||||
$name = $request->input('name');
|
||||
|
|
|
@ -29,7 +29,7 @@ class InAppRegisterEmailVerify extends Mailable
|
|||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: config('pixelfed.domain.app') . ' - Verify Your Email Address',
|
||||
subject: config('pixelfed.domain.app') . __('auth.verifyYourEmailAddress'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,5 +112,5 @@ return [
|
|||
],
|
||||
],
|
||||
|
||||
'iar' => env('APP_REGISTER', false),
|
||||
'in_app_registration' => (bool) env('APP_REGISTER', false),
|
||||
];
|
||||
|
|
|
@ -15,5 +15,5 @@ return [
|
|||
|
||||
'failed' => 'These credentials do not match our records.',
|
||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||
|
||||
'verifyYourEmailAddress' => ' - Verify Your Email Address',
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue