mirror of
https://github.com/flarum/framework.git
synced 2025-02-26 18:15:26 +08:00
Change back to 401 error on invalid login
See 26a821e3e2 (commitcomment-13866552)
This commit is contained in:
parent
6d7b826133
commit
12830265d9
@ -129,18 +129,13 @@ export default class LogInModal extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onerror(error) {
|
onerror(error) {
|
||||||
switch (error.status) {
|
if (error.status === 401) {
|
||||||
case 401:
|
if (error.response.emailConfirmationRequired) {
|
||||||
error.alert.props.children = app.trans('core.forum.log_in_confirmation_required_message', {email: error.response.emailConfirmationRequired});
|
error.alert.props.children = app.trans('core.forum.log_in_confirmation_required_message', {email: error.response.emailConfirmationRequired});
|
||||||
delete error.alert.props.type;
|
delete error.alert.props.type;
|
||||||
break;
|
} else {
|
||||||
|
|
||||||
case 404:
|
|
||||||
error.alert.props.children = app.trans('core.forum.log_in_invalid_login_message');
|
error.alert.props.children = app.trans('core.forum.log_in_invalid_login_message');
|
||||||
break;
|
}
|
||||||
|
|
||||||
default:
|
|
||||||
// no default
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onerror(error);
|
super.onerror(error);
|
||||||
|
@ -236,7 +236,7 @@ export default class App {
|
|||||||
return responseText;
|
return responseText;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.requestError) this.requestError.hideAlert();
|
if (this.requestError) this.alerts.dismiss(this.requestError.alert);
|
||||||
|
|
||||||
// Now make the request. If it's a failure, inspect the error that was
|
// Now make the request. If it's a failure, inspect the error that was
|
||||||
// returned and show an alert containing its contents.
|
// returned and show an alert containing its contents.
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
namespace Flarum\Api\Controller;
|
namespace Flarum\Api\Controller;
|
||||||
|
|
||||||
use Flarum\Api\Command\GenerateAccessToken;
|
use Flarum\Api\Command\GenerateAccessToken;
|
||||||
|
use Flarum\Core\Exception\PermissionDeniedException;
|
||||||
use Flarum\Core\Repository\UserRepository;
|
use Flarum\Core\Repository\UserRepository;
|
||||||
use Flarum\Event\UserEmailChangeWasRequested;
|
use Flarum\Event\UserEmailChangeWasRequested;
|
||||||
use Flarum\Http\Controller\ControllerInterface;
|
use Flarum\Http\Controller\ControllerInterface;
|
||||||
use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher;
|
||||||
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
|
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Zend\Diactoros\Response\JsonResponse;
|
use Zend\Diactoros\Response\JsonResponse;
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class TokenController implements ControllerInterface
|
|||||||
$user = $this->users->findByIdentification($identification);
|
$user = $this->users->findByIdentification($identification);
|
||||||
|
|
||||||
if (! $user || ! $user->checkPassword($password)) {
|
if (! $user || ! $user->checkPassword($password)) {
|
||||||
throw new ModelNotFoundException;
|
throw new PermissionDeniedException;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $user->is_activated) {
|
if (! $user->is_activated) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user