MCPcopy Create free account
hub / github.com/error311/FileRise / issueRememberToken

Method issueRememberToken

src/FileRise/Domain/AuthModel.php:713–726  ·  view source on GitHub ↗

* Issue a new remember-me token and store it hashed on disk. * * @param string $username * @param bool $isAdmin Kept for call-site compatibility; roles are resolved from users.txt on use. * @param int|null $expiry * @return array{token:string,expiry:int} */

(string $username, bool $isAdmin, ?int $expiry = null)

Source from the content-addressed store, hash-verified

711 * @return array{token:string,expiry:int}
712 */
713 public static function issueRememberToken(string $username, bool $isAdmin, ?int $expiry = null): array
714 {
715 $expiry = $expiry ?? (time() + 30 * 24 * 60 * 60);
716 $token = bin2hex(random_bytes(32));
717
718 $all = self::loadRememberTokenStore();
719 $all[self::rememberTokenHash($token)] = [
720 'username' => $username,
721 'expiry' => $expiry
722 ];
723 self::saveRememberTokenStore($all);
724
725 return ['token' => $token, 'expiry' => $expiry];
726 }
727
728 /**
729 * Revoke a remember-me token (hashed or legacy).

Callers 2

finalizeLoginMethod · 0.80
verifyTOTPMethod · 0.80

Calls 3

rememberTokenHashMethod · 0.95

Tested by

no test coverage detected