Skip to content
This repository was archived by the owner on Dec 8, 2020. It is now read-only.

Commit 128ac11

Browse files
committed
Set user's recovery details when creating, and update email text
1 parent 5c5d817 commit 128ac11

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

app/controller/usercontroller.ctrl.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public function recover(){
164164
$headers = "From: " . APPEMAIL . "\r\n";
165165
$headers .= "MIME-Version: 1.0\r\n";
166166
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
167+
$headers .= "Bcc: " . SUPPORT_CONTACT_EMAIL . "\r\n";
167168

168169
$sender = mail($email, $subject, $message, $headers);
169170

@@ -356,18 +357,23 @@ public function create() {
356357
//Send out email
357358

358359
// send email to User
359-
$message = "You just got an account on <strong>" . APPNAME . "</strong>.<br />
360-
Please click on this link to recover your password: <a href=\"" . BASE_URL . "/user/reset/?recovery=" . $data['recovery'] . "\">" . BASE_URL . "/user/reset/?recovery=" . $data['recovery'] . "</a>. <br />
361-
If the link doesn't work, please copy and paste it in the address bar of your browser.<br />
362-
The link will be active for the next 24 hours.";
363-
$subject = APPNAME . ": Password recovery";
360+
$message = "<p>Hi,</p>" .
361+
"<p>This is an automatic email to let you know that we have just created an account for you on the <strong>" . APPNAME . "</strong>.</p>" .
362+
"<p>Please click on this link to set your password: <a href=\"" . BASE_URL . "/user/reset/?recovery=" . $data['recovery'] . "\">" . BASE_URL . "/user/reset/?recovery=" . $data['recovery'] . "</a>.</p>" .
363+
"<p>If the link doesn't work, please copy and paste it in the address bar of your browser.</p>" .
364+
"<p>The link will be active for the next 24 hours.</p>" .
365+
"<p>If you have any issues, please contact <a href='mailto:" . SUPPORT_CONTACT_EMAIL . "'>" . SUPPORT_CONTACT_EMAIL . "</a>.</p>" .
366+
"<p>Thanks for using the " . APPNAME . "!</p>" .
367+
"<p><em>The Restart Project</em></p>";
368+
$subject = APPNAME . ": Account created - please set your password";
364369
$headers = "From: " . APPEMAIL . "\r\n";
365370
$headers .= "MIME-Version: 1.0\r\n";
366371
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
372+
$headers .= "Bcc: " . SUPPORT_CONTACT_EMAIL . "\r\n";
367373

368374
$sender = mail($email, $subject, $message, $headers);
369375

370-
$response['success'] = 'User created correctly.';
376+
$response['success'] = 'User created correctly. <strong>An email has been sent to the user to ask them to set their password.</strong>';
371377
}
372378
else {
373379
$response['danger'] = 'User could not be created';

app/model/user.model.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ public function inGroup($group){
150150
}
151151

152152
public function create($data){
153-
$sql = 'INSERT INTO `' . $this->table . '` (`created_at`, `name`, `email`, `password`, `role`)
154-
VALUES (:created_at, :name, :email, :password, :role)';
153+
$sql = 'INSERT INTO `' . $this->table . '` (`created_at`, `name`, `email`, `password`, `role`, `recovery`, `recovery_expires`)
154+
VALUES (:created_at, :name, :email, :password, :role, :recovery, :recovery_expires)';
155155

156156
$data['created_at'] = date('Y-m-d H:i:s', time() );
157157

@@ -161,6 +161,8 @@ public function create($data){
161161
$stmt->bindParam(':password', $data['password'], PDO::PARAM_STR);
162162
$stmt->bindParam(':role', $data['role'], PDO::PARAM_INT);
163163
$stmt->bindParam(':created_at', $data['created_at']);
164+
$stmt->bindParam(':recovery', $data['recovery']);
165+
$stmt->bindParam(':recovery_expires', $data['recovery_expires']);
164166

165167
$q = $stmt->execute();
166168

0 commit comments

Comments
 (0)