<?php 

class databaseauthenticator implements authenticator {
	
	static function authenticate(string $username, string $password): bool {
		$result=database::queryGetOne('SELECT password FROM user WHERE name=:username', array(':username'=>$username));
		if(!$result){
			return false;
		}
        if(password_verify($password, $result['password'])){ return true; }
		$password=urldecode($password);
        return password_verify($password, $result['password']);
	}
	
}

