function doLogin($user) { system\Helper::arcSetUser($user); Log::createLog("success", "user", "User logged in: " . $user->email); system\Helper::arcCheckSettingExists("ARC_LOGIN_URL", "/"); $url = SystemSetting::getByKey("ARC_LOGIN_URL"); system\Helper::arcReturnJSON(["redirect" => $url->value]); system\Helper::arcAddMessage("success", "Login successful."); }
system\Helper::arcAddMessage("danger", "User already exists with that email address"); return; } $user->firstname = ucfirst(strtolower($_POST["firstname"])); $user->lastname = ucfirst(strtolower($_POST["lastname"])); $user->email = strtolower($_POST["emailr"]); if (empty($user->email)) { system\Helper::arcAddMessage("danger", "Please specifiy an email address"); return; } $user->setPassword($_POST["passwordr"]); // save user $user->update(); $company = SystemSetting::getByKey("ARC_REQUIRECOMPANY"); if (!empty($_POST["company"]) && $company->value == "true") { $comp = Company::getByName(ucwords($_POST["company"])); if ($comp->id == 0) { $comp = new Company(); $comp->name = ucwords($_POST["company"]); $comp->update(); } $user->addToCompany($comp->id); } system\Helper::arcSetUser($user); system\Helper::arcAddMessage("success", "Your details have been registered"); system\Helper::arcCheckSettingExists("ARC_LOGIN_URL", "/"); $url = SystemSetting::getByKey("ARC_LOGIN_URL"); system\Helper::arcReturnJSON(["redirect" => $url->value]); } else { system\Helper::arcAddFooter("js", system\Helper::arcGetModulePath() . "js/register.js"); }