| @@ 70-93 (lines=24) @@ | ||
| 67 | /** |
|
| 68 | * Set or delete the OTP secret for a particular user. |
|
| 69 | */ |
|
| 70 | public function setOtpSecret($userId, $otpSecret) |
|
| 71 | { |
|
| 72 | $otpSecretFile = sprintf('%s/%s', $this->configDir, $userId); |
|
| 73 | ||
| 74 | if (false === $otpSecret) { |
|
| 75 | // remove the secret |
|
| 76 | if ($this->io->isFile($otpSecretFile)) { |
|
| 77 | $this->io->deleteFile($otpSecretFile); |
|
| 78 | ||
| 79 | return true; |
|
| 80 | } |
|
| 81 | ||
| 82 | return false; |
|
| 83 | } |
|
| 84 | ||
| 85 | // set the secret, if it is not yet set, do not allow override |
|
| 86 | if ($this->io->isFile($otpSecretFile)) { |
|
| 87 | return false; |
|
| 88 | } |
|
| 89 | ||
| 90 | $this->io->writeFile($otpSecretFile, $otpSecret, true); |
|
| 91 | ||
| 92 | return true; |
|
| 93 | } |
|
| 94 | } |
|
| 95 | ||
| @@ 57-76 (lines=20) @@ | ||
| 54 | /** |
|
| 55 | * Set or delete the VOOT token for a particular user. |
|
| 56 | */ |
|
| 57 | public function setVootToken($userId, $vootToken) |
|
| 58 | { |
|
| 59 | $vootTokenFile = sprintf('%s/%s', $this->configDir, $userId); |
|
| 60 | ||
| 61 | if (false === $vootToken) { |
|
| 62 | // remove the token |
|
| 63 | if ($this->io->isFile($vootTokenFile)) { |
|
| 64 | $this->io->deleteFile($vootTokenFile); |
|
| 65 | ||
| 66 | return true; |
|
| 67 | } |
|
| 68 | ||
| 69 | return false; |
|
| 70 | } |
|
| 71 | ||
| 72 | // set the token, if it is already set override |
|
| 73 | $this->io->writeFile($vootTokenFile, $vootToken, true); |
|
| 74 | ||
| 75 | return true; |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||