Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
updated the email handling for resets & new users to pass along error…
Browse files Browse the repository at this point in the history
…s to the UI
  • Loading branch information
caseysoftware committed Jan 29, 2013
1 parent c951a06 commit 9fba96c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
11 changes: 8 additions & 3 deletions OpenVBX/controllers/auth/reset.php
Expand Up @@ -110,9 +110,14 @@ public function reset()
else
{
$user = new VBX_User($user);
$user->send_reset_notification();
$this->session->set_flashdata('error',
'To complete the password reset, check your inbox.');
$emailSent = $user->send_reset_notification();
if ($emailSent) {
$this->session->set_flashdata('error',
'To complete the password reset, check your inbox.');
} else {
$this->session->set_flashdata('error',
'The email was not sent. Contact your admin.');
}
return redirect('auth/login');
}

Expand Down
15 changes: 13 additions & 2 deletions OpenVBX/models/vbx_user.php
Expand Up @@ -435,6 +435,12 @@ public function get_active_users()
return self::search(array('is_active' => 1));
}

/*
* This method attempts to send the notification and gives us a true/false
* depending on if it worked.
*
* @return boolean
*/
public function send_reset_notification()
{
// Set a random invitation code for resetting password
Expand All @@ -446,9 +452,14 @@ public function send_reset_notification()
'invite_code' => $this->invite_code,
'reset_url' => tenant_url("/auth/reset/{$this->invite_code}", $this->tenant_id)
);
openvbx_mail($this->email, 'Reset your password', 'password-reset', $maildata);
return openvbx_mail($this->email, 'Reset your password', 'password-reset', $maildata);
}

/*
* This method attempts to send the email and returns a boolean depending on if it worked.
*
* @return boolean
*/
public function send_new_user_notification()
{
// Set a random invitation code for resetting password
Expand All @@ -461,7 +472,7 @@ public function send_new_user_notification()
'name' => $this->first_name,
'reset_url' => tenant_url("/auth/reset/{$this->invite_code}", $this->tenant_id)
);
openvbx_mail($this->email, 'Welcome aboard', 'welcome-user', $maildata);
return openvbx_mail($this->email, 'Welcome aboard', 'welcome-user', $maildata);
}

/**
Expand Down

0 comments on commit 9fba96c

Please sign in to comment.