private static function autoconnect() { $cookie = self::$request->get_cookie(self::$AUTOCONNECT_COOKIE_NAME); $user_id = AutoConnectData::get_user_id_from_cookie($cookie); if ($user_id != Session::VISITOR_SESSION_ID) { return SessionData::create_from_user_id($user_id); } else { self::$response->delete_cookie(self::$AUTOCONNECT_COOKIE_NAME); return self::create_visitor(); } }
public static function change_key($user_id) { $data = new AutoConnectData($user_id, KeyGenerator::generate_key(64)); $data->save_in_db(); return $data; }
public static function update_auth_infos($user_id, $login = null, $approved = null, $password = null, $registration_pass = null, $change_password_pass = null) { if (!empty($login)) { $columns['login'] = $login; } if ($approved !== null) { $columns['approved'] = (int) $approved; } if (!empty($password)) { $columns['password'] = $password; } if ($registration_pass !== null) { $columns['registration_pass'] = $registration_pass; } if ($change_password_pass !== null) { $columns['change_password_pass'] = $change_password_pass; } $condition = 'WHERE user_id=:user_id'; $parameters = array('user_id' => $user_id); PersistenceContext::get_querier()->update(DB_TABLE_INTERNAL_AUTHENTICATION, $columns, $condition, $parameters); UserService::regenerate_cache(); if ($approved !== null && !$approved) { PersistenceContext::get_querier()->delete(DB_TABLE_SESSIONS, $condition, $parameters); AutoConnectData::change_key($user_id); } }