示例#1
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Log in'));
     if (ModelUser::isLoggedIn()) {
         $this->setMessage(lang('Welcome back ' . ModelUser::current()->data->name), 'success', 'main');
         redirect(url('controlpanel.home'));
     }
     if ($this->isPostBack()) {
         $this->post->email->addValidation([new ValidateInputNotNullOrEmpty(), new ValidateInputEmail()]);
         if (!$this->hasErrors()) {
             try {
                 $user = ModelUser::getByUsername($this->input('email'));
                 if ($user->hasRow() && !$user->getEmailConfirmed()) {
                     $this->setError(lang('Please confirm your e-mail.'));
                     response()->refresh();
                 }
                 ModelUser::authenticate($this->input('email'), $this->input('password'));
             } catch (UserException $e) {
                 $this->setError($e->getMessage());
             }
             if (!$this->hasErrors()) {
                 redirect(url('controlpanel.organisations'));
             }
         }
     }
 }
示例#2
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Recover log in'));
     if ($this->isPostBack()) {
         $this->post->email->addValidation(new ValidateInputNotNullOrEmpty());
         if (!$this->hasErrors()) {
             $user = ModelUser::getByUsername($this->input('email'));
             if (!$user->hasRow()) {
                 $this->setMessage('No user found', 'warning');
                 response()->refresh();
             }
             if (!$this->hasErrors()) {
                 $reset = new UserReset($user->id);
                 $reset->save();
                 // TODO: Move this shit to seperate html template
                 $text = "Dear customer!\n\nYou are receiving this mail, because you (or someone else) has requested a password reset for your user on NinjaImg.com.\n\nTo continue with the password reset, please click the link below to confirm the reset:\n\n" . sprintf('https://%s/reset/%s', $_SERVER['HTTP_HOST'], $reset->key) . "\n\nIf you have any questions, feel free to contact us any time.\n\nKind regards,\nThe NinjaImg Team";
                 $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
                 $swift = \Swift_Mailer::newInstance($transport);
                 $message = new \Swift_Message(lang('Confirm password reset on NinjaImg'));
                 $message->setFrom(env('MAIL_FROM'));
                 $message->setSender(env('MAIL_FROM'));
                 $message->setReplyTo(env('MAIL_FROM'));
                 $message->setBody($text, 'text/plain');
                 $message->setTo($user->username);
                 $swift->send($message);
                 $this->setMessage('A password reset link has been sent to your e-mail', 'success');
                 // Send mail to user confirming reset...
                 // Maybe show message with text that are active even when session disappear
                 response()->refresh();
             }
         }
     }
 }
示例#3
0
 public function __construct($key)
 {
     parent::__construct();
     $newPassword = uniqid();
     $reset = \Pecee\Model\User\UserReset::confirm($key, $newPassword);
     if ($reset) {
         $user = ModelUser::getById($reset);
         if ($user->hasRow()) {
             // Send mail with new password
             // TODO: Move this shit to separate html template
             $user->setEmailConfirmed(true);
             $user->update();
             $text = "Dear customer!\n\nWe've reset your password - you can login with your e-mail and the new password provided below:\nNew password: "******"\n\nIf you have any questions, feel free to contact us any time.\n\nKind regards,\nThe NinjaImg Team";
             $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
             $swift = \Swift_Mailer::newInstance($transport);
             $message = new \Swift_Message(lang('New password for NinjaImg'));
             $message->setFrom(env('MAIL_FROM'));
             $message->setSender(env('MAIL_FROM'));
             $message->setReplyTo(env('MAIL_FROM'));
             $message->setBody($text, 'text/plain');
             $message->setTo($user->username);
             $swift->send($message);
             $this->setMessage('A new password has been sent to your e-mail.', 'success');
             redirect(url('user.login'));
         }
         redirect(url('home'));
     }
 }
示例#4
0
 public function __construct()
 {
     parent::__construct();
     $user = ModelUser::getByUsername($this->input('email'));
     if (!$user->hasRow()) {
         $this->setError('Failed to confirm your account');
     } else {
         if ($user->getEmailConfirmed()) {
             $this->setMessage(lang('Your account is already confirmed.'), 'success');
         } else {
             $user->setEmailConfirmed(true);
             $user->update();
             $this->setMessage(lang('Your account has been confirmed, and you are ready to proceed with your login.'), 'success');
         }
     }
     redirect(url('user.login'));
 }
示例#5
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle(lang('Register'));
     $this->currency = ModelSettings::getInstance();
     $role = UserRole::TYPE_OWNER;
     if ($this->get->email->getValue()) {
         $this->invite = OrganisationInvite::getByEmail($this->get->email->getValue());
         if ($this->invite->hasRow()) {
             $this->organisation = ModelOrganisation::getById($this->invite->organisation_id);
             $role = $this->invite->role;
         }
     }
     if ($this->isPostBack()) {
         $this->post->name->addValidation(new ValidateInputNotNullOrEmpty());
         $this->post->email->addValidation(new ValidateInputEmail());
         if ($this->organisation === null || !$this->organisation->hasRow()) {
             $this->post->company->addValidation(new ValidateInputNotNullOrEmpty());
         }
         $this->post->password->addValidation(new ValidateInputNotNullOrEmpty());
         $this->post->terms->addValidation(new ValidateInputNotNullOrEmpty());
         $this->post->password_repeat->addValidation(new ValidateInputNotNullOrEmpty());
         if (!$this->hasErrors()) {
             // Do not create organisation if invite is available
             if ($this->organisation === null || !$this->organisation->hasRow()) {
                 // Check if organisation name is taken
                 if (ModelOrganisation::getByName($this->input('company'))->hasRow()) {
                     $this->setError(lang('An organisation with the name %s already exists - please request an invite from the organisation owner instead.', $this->input('company')));
                     response()->refresh();
                 }
                 $organisation = new ModelOrganisation();
                 $organisation->setName($this->input('company'));
                 $organisation->save();
                 $role = UserRole::TYPE_OWNER;
             } else {
                 $organisation = $this->organisation;
             }
             $user = new ModelUser();
             $user->username = $this->post->email->getValue();
             $user->data->name = $this->input('name');
             $user->setPassword($this->input('password'));
             try {
                 $user->save();
                 $this->sendWelcomeMail($user);
             } catch (UserException $e) {
                 if ($e->getCode() === ModelUser::ERROR_TYPE_EXISTS) {
                     $error = lang('The e-mail is already registered.');
                 } else {
                     $error = $e->getMessage();
                 }
                 $this->setError($error);
                 response()->refresh();
             }
             $user->addOrganisation($organisation, $role);
             $user->auth();
             // Delete invite
             if ($this->invite && $this->invite->hasRow()) {
                 $this->invitationAcceptedMail($this->invite, $organisation, $user);
                 $this->invite->delete();
             }
             redirect(url('controlpanel.organisations'));
         }
     }
 }
示例#6
0
 public function __construct()
 {
     parent::__construct();
     $this->prependSiteTitle('404: page not found');
     $this->mainMenu->getItem(0)->addClass('active');
 }