show passkey login URL at usercp

This commit is contained in:
xiaomlove
2022-07-06 15:23:23 +08:00
parent 889413e2a8
commit f4df7da0e4
5 changed files with 15 additions and 6 deletions

View File

@@ -46,12 +46,15 @@ class AuthenticateController extends Controller
public function passkeyLogin($passkey) public function passkeyLogin($passkey)
{ {
$user = User::query()->where('passkey', $passkey)->first(['id', 'passhash']); $deadline = Setting::get('security.login_secret_deadline');
if ($user) { if ($deadline && $deadline > now()->toDateTimeString()) {
$passhash = md5($user->passhash . $_SERVER["REMOTE_ADDR"]); $user = User::query()->where('passkey', $passkey)->first(['id', 'passhash']);
logincookie($user->id, $passhash,false,0x7fffffff, true, true, true); if ($user) {
$user->last_login = now(); $passhash = md5($user->passhash . $_SERVER["REMOTE_ADDR"]);
$user->save(); logincookie($user->id, $passhash,false,0x7fffffff, true, true, true);
$user->last_login = now();
$user->save();
}
} }
return redirect('index.php'); return redirect('index.php');
} }

View File

@@ -251,6 +251,7 @@ $lang_usercp = array
'text_two_step_secret_bind_manually_note' => '或者在 APP 中手动输入以下 Key', 'text_two_step_secret_bind_manually_note' => '或者在 APP 中手动输入以下 Key',
'text_two_step_secret_bind_complete_note' => '输入 code 完成两步验证', 'text_two_step_secret_bind_complete_note' => '输入 code 完成两步验证',
'text_two_step_secret_unbind_note' => '输入 code 取消两步验证', 'text_two_step_secret_unbind_note' => '输入 code 取消两步验证',
'row_passkey_login_url' => 'Passkey 登录链接',
); );
?> ?>

View File

@@ -249,6 +249,7 @@ $lang_usercp = array
'text_two_step_secret_bind_manually_note' => '或者在 APP 中手動輸入以下 Key', 'text_two_step_secret_bind_manually_note' => '或者在 APP 中手動輸入以下 Key',
'text_two_step_secret_bind_complete_note' => '輸入 code 完成兩步驗證', 'text_two_step_secret_bind_complete_note' => '輸入 code 完成兩步驗證',
'text_two_step_secret_unbind_note' => '輸入 code 取消兩步驗證', 'text_two_step_secret_unbind_note' => '輸入 code 取消兩步驗證',
'row_passkey_login_url' => 'Passkey 登錄鏈接',
); );
?> ?>

View File

@@ -251,6 +251,7 @@ $lang_usercp = array
'text_two_step_secret_bind_manually_note' => 'Or manually enter the following key in the APP: ', 'text_two_step_secret_bind_manually_note' => 'Or manually enter the following key in the APP: ',
'text_two_step_secret_bind_complete_note' => 'Enter code to complete the two-step authentication', 'text_two_step_secret_bind_complete_note' => 'Enter code to complete the two-step authentication',
'text_two_step_secret_unbind_note' => 'Enter code to cancel two-step authentication', 'text_two_step_secret_unbind_note' => 'Enter code to cancel two-step authentication',
'row_passkey_login_url' => 'Passkey login URL',
); );
?> ?>

View File

@@ -933,6 +933,9 @@ else{
if ($CURUSER["avatar"]) if ($CURUSER["avatar"])
tr_small($lang_usercp['row_avatar'], "<img src=\"" . $CURUSER["avatar"] . "\" border=0>", 1); tr_small($lang_usercp['row_avatar'], "<img src=\"" . $CURUSER["avatar"] . "\" border=0>", 1);
tr_small($lang_usercp['row_passkey'], $CURUSER["passkey"], 1); tr_small($lang_usercp['row_passkey'], $CURUSER["passkey"], 1);
if (get_setting('security.login_type') == 'passkey' && get_setting('security.login_secret_deadline') > date('Y-m-d H:i:s')) {
tr_small($lang_usercp['row_passkey_login_url'], sprintf('%s/%s/%s', getSchemeAndHttpHost(), get_setting('security.login_secret'), $CURUSER['passkey']), 1);
}
if ($prolinkpoint_bonus) if ($prolinkpoint_bonus)
{ {
$prolinkclick=get_row_count("prolinkclicks", "WHERE userid=".$CURUSER['id']); $prolinkclick=get_row_count("prolinkclicks", "WHERE userid=".$CURUSER['id']);