public function do(string $old = NULL, string $new = NULL, string $newAgain = NULL, array $data = []) : bool { if (Factory::class('Login')->is()) { $old = Properties::$parameters['oldPassword'] ?? $old; $new = Properties::$parameters['newPassword'] ?? $new; $newAgain = Properties::$parameters['passwordAgain'] ?? $newAgain; $data = Properties::$parameters['column'] ?? $data; Properties::$parameters = []; if (empty($newAgain)) { $newAgain = $new; } $getColumns = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['columns']; $getJoining = INDIVIDUALSTRUCTURES_USER_CONFIG['joining']; $joinTables = $getJoining['tables']; $jc = $getJoining['column']; $pc = $getColumns['password']; $uc = $getColumns['username']; $tn = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['table']; $encodeType = INDIVIDUALSTRUCTURES_USER_CONFIG['encode']; $oldPassword = !empty($encodeType) ? Encode::type($old, $encodeType) : $old; $newPassword = !empty($encodeType) ? Encode::type($new, $encodeType) : $new; $newPasswordAgain = !empty($encodeType) ? Encode::type($newAgain, $encodeType) : $newAgain; if (!empty($joinTables)) { $joinData = $data; $data = $data[$tn] ?? [$tn]; } $getUserData = Factory::class('Data')->get($tn); $username = $getUserData->{$uc}; $password = $getUserData->{$pc}; if ($oldPassword != $password) { return !($this->error = lang('IndividualStructures', 'user:oldPasswordError')); } elseif ($newPassword != $newPasswordAgain) { return !($this->error = lang('IndividualStructures', 'user:passwordNotMatchError')); } else { $data[$pc] = $newPassword; $data[$uc] = $username; if (!empty($joinTables)) { $joinCol = DB::where($uc, $username)->get($tn)->row()->{$jc}; foreach ($joinTables as $table => $joinColumn) { if (isset($joinData[$table])) { DB::where($joinColumn, $joinCol)->update($table, $joinData[$table]); } } } else { if (!DB::where($uc, $username)->update($tn, $data)) { return !($this->error = lang('IndividualStructures', 'user:registerUnknownError')); } } return $this->success = lang('IndividualStructures', 'user:updateProcessSuccess'); } } else { return false; } }
public function do(string $email = NULL, string $returnLinkPath = NULL) : bool { $email = Properties::$parameters['email'] ?? $email; $returnLinkPath = Properties::$parameters['returnLink'] ?? $returnLinkPath; Properties::$parameters = []; // ------------------------------------------------------------------------------ // Settings // ------------------------------------------------------------------------------ $tableName = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['table']; $senderInfo = INDIVIDUALSTRUCTURES_USER_CONFIG['emailSenderInfo']; $getColumns = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['columns']; $usernameColumn = $getColumns['username']; $passwordColumn = $getColumns['password']; $emailColumn = $getColumns['email']; // ------------------------------------------------------------------------------ if (!empty($emailColumn)) { DB::where($emailColumn, $email); } else { DB::where($usernameColumn, $email); } $row = DB::get($tableName)->row(); if (isset($row->{$usernameColumn})) { if (!isUrl($returnLinkPath)) { $returnLinkPath = siteUrl($returnLinkPath); } $encodeType = INDIVIDUALSTRUCTURES_USER_CONFIG['encode']; $newPassword = Encode::create(10); $encodePassword = !empty($encodeType) ? Encode::type($newPassword, $encodeType) : $newPassword; $templateData = array('usernameColumn' => $row->{$usernameColumn}, 'newPassword' => $newPassword, 'returnLinkPath' => $returnLinkPath); $message = Import::template('UserEmail/ForgotPassword', $templateData, true); Email::sender($senderInfo['mail'], $senderInfo['name'])->receiver($email, $email)->subject(lang('IndividualStructures', 'user:newYourPassword'))->content($message); if (Email::send()) { if (!empty($emailColumn)) { DB::where($emailColumn, $email); } else { DB::where($usernameColumn, $email); } if (DB::update($tableName, [$passwordColumn => $encodePassword])) { return $this->success = lang('IndividualStructures', 'user:forgotPasswordSuccess'); } return !($this->error = lang('Database', 'updateError')); } else { return !($this->error = lang('IndividualStructures', 'user:emailError')); } } else { return !($this->error = lang('IndividualStructures', 'user:forgotPasswordError')); } }
public function do(array $data = NULL, $autoLogin = false, string $activationReturnLink = NULL) : bool { $data = Properties::$parameters['column'] ?? $data; $autoLogin = Properties::$parameters['autoLogin'] ?? $autoLogin; $activationReturnLink = Properties::$parameters['returnLink'] ?? $activationReturnLink; Properties::$parameters = []; // ------------------------------------------------------------------------------ // Settings // ------------------------------------------------------------------------------ $getColumns = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['columns']; $getJoining = INDIVIDUALSTRUCTURES_USER_CONFIG['joining']; $tableName = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['table']; $joinTables = $getJoining['tables']; $joinColumn = $getJoining['column']; $usernameColumn = $getColumns['username']; $passwordColumn = $getColumns['password']; $emailColumn = $getColumns['email']; $activeColumn = $getColumns['active']; $activationColumn = $getColumns['activation']; // ------------------------------------------------------------------------------ if (!empty($joinTables)) { $joinData = $data; $data = isset($data[$tableName]) ? $data[$tableName] : [$tableName]; } if (!isset($data[$usernameColumn]) || !isset($data[$passwordColumn])) { return !($this->error = lang('IndividualStructures', 'user:registerUsernameError')); } $loginUsername = $data[$usernameColumn]; $loginPassword = $data[$passwordColumn]; $encodeType = INDIVIDUALSTRUCTURES_USER_CONFIG['encode']; $encodePassword = !empty($encodeType) ? Encode::type($loginPassword, $encodeType) : $loginPassword; $usernameControl = DB::where($usernameColumn, $loginUsername)->get($tableName)->totalRows(); // Daha önce böyle bir kullanıcı // yoksa kullanıcı kaydetme işlemini başlat. if (empty($usernameControl)) { $data[$passwordColumn] = $encodePassword; if (!DB::insert($tableName, $data)) { return !($this->error = lang('IndividualStructures', 'user:registerUnknownError')); } if (!empty($joinTables)) { $joinCol = DB::where($usernameColumn, $loginUsername)->get($tableName)->row()->{$joinColumn}; foreach ($joinTables as $table => $joinColumn) { $joinData[$table][$joinTables[$table]] = $joinCol; DB::insert($table, $joinData[$table]); } } $this->success = lang('IndividualStructures', 'user:registerSuccess'); if (!empty($activationColumn)) { if (!isEmail($loginUsername)) { $email = $data[$emailColumn]; } else { $email = NULL; } $this->_activation($loginUsername, $encodePassword, $activationReturnLink, $email); } else { if ($autoLogin === true) { Factory::class('Login')->do($loginUsername, $loginPassword); } elseif (is_string($autoLogin)) { redirect($autoLogin); } } return true; } else { return !($this->error = lang('IndividualStructures', 'user:registerError')); } }
public function do(string $un = NULL, string $pw = NULL, $rememberMe = false) : bool { $un = Properties::$parameters['username'] ?? $un; $pw = Properties::$parameters['password'] ?? $pw; $rememberMe = Properties::$parameters['remember'] ?? $rememberMe; Properties::$parameters = []; if (!is_scalar($rememberMe)) { $rememberMe = false; } $username = $un; $encodeType = INDIVIDUALSTRUCTURES_USER_CONFIG['encode']; $password = !empty($encodeType) ? Encode::type($pw, $encodeType) : $pw; // ------------------------------------------------------------------------------ // Settings // ------------------------------------------------------------------------------ $tableName = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['table']; $getColumns = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['columns']; $passwordColumn = $getColumns['password']; $usernameColumn = $getColumns['username']; $emailColumn = $getColumns['email']; $bannedColumn = $getColumns['banned']; $activeColumn = $getColumns['active']; $activationColumn = $getColumns['activation']; // ------------------------------------------------------------------------------ $r = DB::where($usernameColumn, $username)->get($tableName)->row(); if (!isset($r->{$passwordColumn})) { return !($this->error = lang('IndividualStructures', 'user:loginError')); } $passwordControl = $r->{$passwordColumn}; $bannedControl = ''; $activationControl = ''; if (!empty($bannedColumn)) { $banned = $bannedColumn; $bannedControl = $r->{$banned}; } if (!empty($activationColumn)) { $activationControl = $r->{$activationColumn}; } if (!empty($r->{$usernameColumn}) && $passwordControl == $password) { if (!empty($bannedColumn) && !empty($bannedControl)) { return !($this->error = lang('IndividualStructures', 'user:bannedError')); } if (!empty($activationColumn) && empty($activationControl)) { return !($this->error = lang('IndividualStructures', 'user:activationError')); } Session::insert($usernameColumn, $username); Session::insert($passwordColumn, $password); if (Method::post($rememberMe) || !empty($rememberMe)) { if (Cookie::select($usernameColumn) !== $username) { Cookie::insert($usernameColumn, $username); Cookie::insert($passwordColumn, $password); } } if (!empty($activeColumn)) { DB::where($usernameColumn, $username)->update($tableName, [$activeColumn => 1]); } return $this->success = lang('IndividualStructures', 'user:loginSuccess'); } else { return !($this->error = lang('IndividualStructures', 'user:loginError')); } }