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

Method authenticate

src/FileRise/Domain/AuthModel.php:261–283  ·  view source on GitHub ↗

* Authenticates the user using form-based credentials. * * @param string $username * @param string $password * @return array|false Returns an associative array with user data (role, totp_secret) on success or false on failure. */

(string $username, string $password)

Source from the content-addressed store, hash-verified

259 * @return array|false Returns an associative array with user data (role, totp_secret) on success or false on failure.
260 */
261 public static function authenticate(string $username, string $password)
262 {
263 $usersFile = USERS_DIR . USERS_FILE;
264 if (!file_exists($usersFile)) {
265 return false;
266 }
267 $lines = file($usersFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
268 foreach ($lines as $line) {
269 $parts = explode(':', trim($line));
270 if (count($parts) < 3) {
271 continue;
272 }
273 if ($username === $parts[0] && password_verify($password, $parts[1])) {
274 return [
275 'role' => $parts[2],
276 'totp_secret' => (isset($parts[3]) && !empty($parts[3]))
277 ? decryptData($parts[3], $GLOBALS['encryptionKey'])
278 : null
279 ];
280 }
281 }
282 return false;
283 }
284
285 public static function authenticateWebDav(string $username, string $password): bool
286 {

Callers 4

authenticateWebDavMethod · 0.95
handleOidcFlowMethod · 0.80
handleFormLoginMethod · 0.80
loginBasicMethod · 0.80

Calls 1

decryptDataFunction · 0.85

Tested by

no test coverage detected