Skip to content

Commit

Permalink
fixup! Testing the addition of email auth to login
Browse files Browse the repository at this point in the history
  • Loading branch information
miaulalala committed Oct 4, 2022
1 parent 1f94f15 commit cc7f391
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/Provider/AtLoginProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AtLoginProvider implements ILoginSetupProvider {
private $myUser;

/** @var EmailService */
private $EmailService;
private $emailService;

/** @var OCCONFIG */
private $occonfig;
Expand All @@ -36,7 +36,7 @@ class AtLoginProvider implements ILoginSetupProvider {
public function __construct(IUser $myUser, $mySecret, EmailService $EmailService, OCCONFIG $occonfig, IRegistry $registry, Email $provider, StateStorage $stateStorage) {
$this->myUser = $myUser;
$this->mySecret = $mySecret;
$this->EmailService = $EmailService;
$this->emailService = $EmailService;
$this->occonfig = $occonfig;
$this->registry = $registry;
$this->provider = $provider;
Expand All @@ -47,14 +47,17 @@ private function setEnabledActivity() {
$isEnforced = $this->occonfig->getSystemValue('twofactor_enforced');
if ($isEnforced) {
$this->registry->enableProviderFor($this->provider, $this->myUser);
$state = new State($this->myUser, EmailProvider::STATE_ENABLED);
$this->stateStorage->persist($state->verify());
}
$state = new State($this->myUser, EmailProvider::STATE_ENABLED);
$this->stateStorage->persist($state->verify());
}

public function getBody(): Template {
if($this->myUser->getEMailAddress() === null) {
return new Template('twofactor_email', 'error_email_empty');
}
try {
$this->EmailService->send($this->myUser, $this->mySecret);
$this->emailService->send($this->myUser, $this->mySecret);
} catch (\Exception $ex) {
return new Template('twofactor_email', 'error');
}
Expand Down
3 changes: 3 additions & 0 deletions templates/error_email_empty.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<fieldset class="warning">
<?php p($l->t('Error: you do not have an email address set. Please use a different 2FA method or ask your administrator to set up your email address for you.')); ?>
</fieldset>

0 comments on commit cc7f391

Please sign in to comment.