-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1781 - fix 405 error during twostep workflow from user settings page #1968
Conversation
@@ -317,6 +317,7 @@ | |||
Route::get('/{username}/settings/privacy{hash?}', [App\Http\Controllers\UserController::class, 'privacy'])->name('user_privacy'); | |||
Route::get('/{username}/settings/security{hash?}', [App\Http\Controllers\UserController::class, 'security'])->name('user_security'); | |||
Route::get('/{username}/settings/notification{hash?}', [App\Http\Controllers\UserController::class, 'notification'])->name('user_notification'); | |||
Route::get('/{username}/settings/change_twostep', [App\Http\Controllers\UserController::class, 'changeTwoStep']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glennforrest Im confused by this as its already defined
UNIT3D-Community-Edition/routes/web.php
Line 344 in dcbef0d
Route::post('/{username}/settings/change_twostep', [App\Http\Controllers\UserController::class, 'changeTwoStep'])->name('change_twostep'); |
Is used here
UNIT3D-Community-Edition/resources/views/user/security.blade.php
Lines 158 to 183 in 51402ce
@if (config('auth.TwoStepEnabled') == true) | |
<div role="tabpanel" class="tab-pane" id="twostep"> | |
<form role="form" method="POST" | |
action="{{ route('change_twostep', ['username' => $user->username]) }}"> | |
@csrf | |
<div class="well"> | |
<h2 class="text-bold">Two Step Authentication</h2> | |
<hr> | |
<label for="twostep" class="control-label">Use Two Step Auth?</label> | |
<div class="radio-inline"> | |
<label><input type="radio" name="twostep" @if ($user->twostep == 1) checked @endif | |
value="1">@lang('common.yes')</label> | |
</div> | |
<div class="radio-inline"> | |
<label><input type="radio" name="twostep" @if ($user->twostep == 0) checked | |
@endif value="0">@lang('common.no')</label> | |
</div> | |
<br> | |
</div> | |
<div class="well text-center"> | |
<button type="submit" class="btn btn-primary">Save Changes</button> | |
</div> | |
</form> | |
</div> | |
</div> | |
@endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, so my idea about a fix for this was basically to just create a redirect to prevent the 405 method not allowed error by defining the GET route. So I just chucked this in the existing controller method, I figured this would be an easier fix than dealing with the whole nextURI
set up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
@@ -318,6 +318,10 @@ public function security(Request $request, $username): \Illuminate\Contracts\Vie | |||
*/ | |||
protected function changeTwoStep(Request $request) | |||
{ | |||
if ($request->getMethod() == 'GET') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this is done when its a POST route.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can define both in laravel routes, similar to how a PUT request to /posts/{post} typically resolves to an update request whereas a DELETE request to the same uri
/posts/{post}` resolves to a destroy/delete method.
Can shift this to a completely separate method on the controller if you'd prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No its fine.
Addresses the 405 error described in the following issue