private function validateForm()
{
// is the form submitted
if ($this->frm->isSubmitted()) {
// get fields
$txtEmail = $this->frm->getField('email');
$txtPassword = $this->frm->getField('password');
$chkRemember = $this->frm->getField('remember');
// required fields
$txtEmail->isFilled(FL::getError('EmailIsRequired'));
$txtPassword->isFilled(FL::getError('PasswordIsRequired'));
// both fields filled in
if ($txtEmail->isFilled() && $txtPassword->isFilled()) {
// valid email?
if ($txtEmail->isEmail(FL::getError('EmailIsInvalid'))) {
// get the status for the given login
$loginStatus = FrontendProfilesAuthentication::getLoginStatus($txtEmail->getValue(), $txtPassword->getValue());
// valid login?
if ($loginStatus !== FrontendProfilesAuthentication::LOGIN_ACTIVE) {
// get the error string to use
$errorString = sprintf(FL::getError('Profiles' . \SpoonFilter::toCamelCase($loginStatus) . 'Login'), FrontendNavigation::getURLForBlock('Profiles', 'ResendActivation'));
// add the error to stack
$this->frm->addError($errorString);
// add the error to the template variables
$this->tpl->assign('loginError', $errorString);
}
}
}
// valid login
if ($this->frm->isCorrect()) {
// get profile id
$profileId = FrontendProfilesModel::getIdByEmail($txtEmail->getValue());
// login
FrontendProfilesAuthentication::login($profileId, $chkRemember->getChecked());
// update salt and password for Dieter's security features
FrontendProfilesAuthentication::updatePassword($profileId, $txtPassword->getValue());
// trigger event
FrontendModel::triggerEvent('Profiles', 'after_logged_in', array('id' => $profileId));
// query string
$queryString = urldecode(\SpoonFilter::getGetValue('queryString', null, SITE_URL));
// redirect
$this->redirect($queryString);
}
}
}