protected function afterLogin($fromCookie) { if (!$fromCookie) { $user = UserCredentials::model()->findByPK(Yii::app()->user->id); $user->last_login_time = new CDbExpression('NOW()'); $user->last_login_ip = SecurityUtils::getRealIp(); $user->save(); } }
public static function createUser($data) { $profile = new UserProfiles(); $profile->dob = '1988-11-11'; $profile->attributes = $data; $profile->salt = SecurityUtils::generateSalt($profile->email_id); $profile->activation_code = SecurityUtils::generateRandomString(10); $profile->registered_ip = SecurityUtils::getRealIp(); return $profile->save(); }
public static function createUser($credential, $profile, $role = "Member") { $password = $credential->password; $credential->salt = SecurityUtils::generateSalt($credential->email_id); $credential->activation_code = SecurityUtils::generateRandomString(10); $credential->registered_ip = SecurityUtils::getRealIp(); $credential->password = SecurityUtils::encryptPassword($credential->password, $credential->salt); $credential->password_confirm = $credential->password; if ($credential->save()) { $profile->user_id = $credential->id; if ($profile->save()) { $assignment = new Assignments(); $assignment->itemname = $role; $assignment->userid = $credential->id; $assignment->data = 's:0:"";'; $assignment->save(); return array('credential' => $credential, 'profile' => $profile); } else { $credential->delete(); $credential->setIsNewRecord(true); return false; } } else { $credential->password = $password; $credential->password_confirm = $password; return false; } }