Hi,
I am making a custom action for the Uniform plugin by @mzur. All set up great so far, but I am struggling to get the right error message showing for specific points. This is what I have:
<?php
namespace Uniform\Actions;
use Kirby\Cms\App;
use Kirby\Toolkit\I18n;
/**
* Action to log in a user.
*/
class SigninAction extends Action
{
/**
* Log in a user using email and password.
*/
public function perform() {
$email = $this->form->data('email');
$password = $this->form->data('password');
try {
kirby()->auth()->login($email, $password);
$role = kirby()->user()->role();
if($role != 'participant') {
kirby()->user()->logout();
$this->fail('You are not a participant yet');
}
} catch (\Exception $e) {
$this->fail('That email and password combination is not recognised');
}
}
}
If the user exists but does not a have a role of participant, I want to show the first message. If the login fails I need to show the second one. However, when using details that should trigger the first message I am getting the second one. Can anyone shed any light on this?