diff --git a/application/config/routes.php b/application/config/routes.php index fbe6136..0d45370 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -74,7 +74,7 @@ $route['f/(:any)'] = '/file/open/$1'; $route['f/(:any)/(:any)'] = '/file/open/$1/$2'; $route['logout'] = 'login/logout'; - $route['activate'] = 'login/activate'; + $route['activate/(:any)/(:any)'] = 'login/activate/$1/$2'; $route['register'] = 'login'; $route['reset/(:any)/(:any)'] = 'login/reset/$1/$2'; $route['tools/twitch/(:any)'] = 'tools/twitch?twich-channel=$1'; diff --git a/application/models/EmailModel.php b/application/models/EmailModel.php new file mode 100644 index 0000000..acd4ee5 --- /dev/null +++ b/application/models/EmailModel.php @@ -0,0 +1,29 @@ +load->library('email'); + + $config['mailtype'] = 'html'; + $this->email->initialize($config); + + $this->email->from('no-reply@kingofdog.eu', 'KingOfDog'); + $this->email->to($recipient); + + $this->email->subject($subject); + $this->email->message($this->load->view('emails/', $template, $templateData, true)); + + $this->email->send(); + } + + } \ No newline at end of file diff --git a/application/models/LoginModel.php b/application/models/LoginModel.php index 097006f..e31d271 100644 --- a/application/models/LoginModel.php +++ b/application/models/LoginModel.php @@ -8,6 +8,7 @@ { parent::__construct(); $this->load->model('NotificationModel', '', TRUE); + $this->load->model('EmailModel', '', TRUE); $this->load->helper('cookie'); } @@ -118,23 +119,9 @@ $this->db->cache_delete('admin', 'users'); - $this->load->library('email'); - - $config['mailtype'] = 'html'; - $this->email->initialize($config); - - $this->email->from('no-reply@kingofdog.eu', 'KingOfDog'); - $this->email->to($email); - - $this->email->subject('Aktiviere deinen Account und lege so richtig los auf KingOfDog.eu'); - $this->email->message($this->load->view('emails/register', ['username' => $username, 'emailHash' => md5($email), 'activationKey' => $activation_key], true)); - - $this->email->send(); + $this->EmailModel->sendMail($email, 'Aktiviere deinen Account und lege so richtig los auf KingOfDog.eu', 'register', ['username' => $username, 'emailHash' => md5($email), 'activationKey' => $activation_key]); // TODO: TRANSLATE -// $message = "Hallo, bitte aktiviere deinen Account: " . base_url('activate/' . md5($email) . '/' . $activation_key); - // TODO: Send email -// mail($email, "Aktiviere deinen Account und lege so richtig los auf KingOfDog.eu", $message); // Send notification $createdUser = $this->db->query('SELECT ID FROM users WHERE username = ?', [$username])->result_array();