aboutsummaryrefslogtreecommitdiff
path: root/Psso/Challenge
diff options
context:
space:
mode:
Diffstat (limited to 'Psso/Challenge')
-rw-r--r--Psso/Challenge/Username.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/Psso/Challenge/Username.php b/Psso/Challenge/Username.php
index 43de085..c8fa762 100644
--- a/Psso/Challenge/Username.php
+++ b/Psso/Challenge/Username.php
@@ -1,6 +1,6 @@
<?php
namespace Psso\Challenge;
-use Psso\{Challenge, AuthProvider, ChallengeResult, Input};
+use Psso\{Challenge, AuthProvider, AuthInterface, ChallengeResult, Input};
/** Just asks for a username and sets it in the context. Always succeeds. */
class Username extends Challenge {
@@ -11,6 +11,14 @@ class Username extends Challenge {
public function validate(
AuthProvider $provider, array $inputData
): ChallengeResult {
- return new ChallengeResult(self::class, true, $inputData['user'], null);
+ $success = true;
+ $message = null;
+ if ($provider instanceof AuthInterface\UserExists) {
+ $success = $provider->userExists($inputData['user']);
+ if (!$success) $message = 'challenge.message.wrong-username';
+ }
+ return new ChallengeResult(
+ self::class, $success, $inputData['user'], $message
+ );
}
}