Base
This commit is contained in:
56
app/Controller/Auth.php
Normal file
56
app/Controller/Auth.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Definition\Controller;
|
||||
use App\Contract\Auth as sAuth;
|
||||
|
||||
class Auth
|
||||
{
|
||||
use Controller;
|
||||
|
||||
public static function login()
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
public static function do_login()
|
||||
{
|
||||
$name = post('name');
|
||||
$password = post('password');
|
||||
$bool = sAuth::login($name, $password);
|
||||
if ($bool) {
|
||||
header('Location: .');
|
||||
} else {
|
||||
header('Location: ' . url('', ['p' => 'auth', 'a' => 'login']));
|
||||
}
|
||||
}
|
||||
public static function logout()
|
||||
{
|
||||
sAuth::logout();
|
||||
header('Location: .');
|
||||
}
|
||||
public static function check_pass()
|
||||
{
|
||||
if (\password_verify(post('password'), sAuth::User()->password)) {
|
||||
return 'OK';
|
||||
}
|
||||
return 'KO';
|
||||
}
|
||||
public static function change_pass()
|
||||
{
|
||||
return view('auth.change_pass');
|
||||
}
|
||||
public static function do_change_pass()
|
||||
{
|
||||
if (\password_verify(post('old'), sAuth::User()->password)) {
|
||||
if (post('new') == post('new2')) {
|
||||
$user = sAuth::User();
|
||||
$user->password(post('new'));
|
||||
$user->save();
|
||||
header('Location: .');
|
||||
die();
|
||||
}
|
||||
}
|
||||
header('Location: ' . url('', ['p' => 'auth', 'a' => 'change_pass']));
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user