X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FLogin_token.php;h=20d5d9dbcefcb3c62b9a9bfe8a7cf894f245a292;hb=3d835bb8b5473783fffb571ccc7f51b6b82b225e;hp=bd6381f9034b6650e87f8243d120251df2a67826;hpb=384a50a7800abde62e040ea57872dc06c0519047;p=quix0rs-gnu-social.git diff --git a/classes/Login_token.php b/classes/Login_token.php index bd6381f903..20d5d9dbce 100644 --- a/classes/Login_token.php +++ b/classes/Login_token.php @@ -1,6 +1,6 @@ id); + + if (!empty($login_token)) { + $login_token->delete(); + } + + $login_token = new Login_token(); + + $login_token->user_id = $user->id; + $login_token->token = common_good_rand(16); + $login_token->created = common_sql_now(); + + $result = $login_token->insert(); + + if (!$result) { + common_log_db_error($login_token, 'INSERT', __FILE__); + // TRANS: Exception thrown when trying creating a login token failed. + // TRANS: %s is the user nickname for which token creation failed. + throw new Exception(sprintf(_('Could not create login token for %s'), + $user->nickname)); + } + + return $login_token; + } }