Merge pull request #143 from ThomasRubini/user_time
This commit is contained in:
commit
6c571f3a62
@ -7,6 +7,10 @@ ini_set("session.cookie_lifetime", $__SESSION_TIMEOUT);
|
|||||||
final class UserController
|
final class UserController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static function currentDate(){
|
||||||
|
return date("Y-m-d H:i:s");
|
||||||
|
}
|
||||||
|
|
||||||
public function loginAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
public function loginAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
||||||
{
|
{
|
||||||
if (Session::is_login()) {
|
if (Session::is_login()) {
|
||||||
@ -53,6 +57,9 @@ final class UserController
|
|||||||
return header("Location: /user/login");
|
return header("Location: /user/login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$O_user->S_LAST_SEEN = self::currentDate();
|
||||||
|
$O_user->update();
|
||||||
|
|
||||||
Session::set_login($O_user->I_ID);
|
Session::set_login($O_user->I_ID);
|
||||||
|
|
||||||
self::redirectToPreviousPage($A_postParams);
|
self::redirectToPreviousPage($A_postParams);
|
||||||
@ -81,7 +88,7 @@ final class UserController
|
|||||||
|
|
||||||
$S_password_hash = password_hash($S_password, PASSWORD_DEFAULT);
|
$S_password_hash = password_hash($S_password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
$O_user = new UserModel($S_email, $S_username, $S_password_hash, null, date("Y-m-d"), 0, 0);
|
$O_user = UserModel::createFull($S_email, $S_username, $S_password_hash, self::currentDate(), self::currentDate(), 0, 0);
|
||||||
$O_user->insert();
|
$O_user->insert();
|
||||||
|
|
||||||
Session::set_login($O_user->I_ID);
|
Session::set_login($O_user->I_ID);
|
||||||
|
@ -45,10 +45,11 @@ final class UserModel extends UserSessionModel
|
|||||||
|
|
||||||
public function insert(){
|
public function insert(){
|
||||||
$O_model = Model::get();
|
$O_model = Model::get();
|
||||||
$stmt = $O_model->prepare("INSERT INTO USER (EMAIL, USERNAME, PASS_HASH, FIRST_SEEN) VALUES(:email, :username, :password_hash, :first_seen)");
|
$stmt = $O_model->prepare("INSERT INTO USER (EMAIL, USERNAME, PASS_HASH, FIRST_SEEN, LAST_SEEN) VALUES(:email, :username, :password_hash, :first_seen, :last_seen)");
|
||||||
$stmt->bindParam("email", $this->S_EMAIL);
|
$stmt->bindParam("email", $this->S_EMAIL);
|
||||||
$stmt->bindParam("username", $this->S_USERNAME);
|
$stmt->bindParam("username", $this->S_USERNAME);
|
||||||
$stmt->bindParam("password_hash", $this->S_PASSWORD_HASH);
|
$stmt->bindParam("password_hash", $this->S_PASSWORD_HASH);
|
||||||
|
$stmt->bindParam("last_seen", $this->S_LAST_SEEN);
|
||||||
$stmt->bindParam("first_seen", $this->S_FIRST_SEEN);
|
$stmt->bindParam("first_seen", $this->S_FIRST_SEEN);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$this->I_ID = Model::get()->lastInsertId();
|
$this->I_ID = Model::get()->lastInsertId();
|
||||||
|
Loading…
Reference in New Issue
Block a user