true, 'email' => true, 'password' => true, 'confirm_password' => true, 'first_name' => true, 'last_name' => true, 'token' => true, 'token_expires' => true, 'api_token' => true, 'activation_date' => true, //tos is a boolean, coming from the "accept the terms of service" checkbox but it is not stored onto database 'tos' => true, 'tos_date' => true, 'active' => true, 'social_accounts' => true, 'current_password' => true ]; /** * @param string $password password that will be set. * @return bool|string */ protected function _setPassword($password) { return (new DefaultPasswordHasher)->hash($password); } /** * @param string $password password that will be confirm. * @return bool|string */ protected function _setConfirmPassword($password) { return (new DefaultPasswordHasher)->hash($password); } /** * Checks if a password is correctly hashed * @param string $password password that will be check. * @param string $hashedPassword hash used to check password. * @return bool */ public function checkPassword($password, $hashedPassword) { return (new DefaultPasswordHasher)->check($password, $hashedPassword); } /** * Returns if the token has already expired * * @return bool */ public function tokenExpired() { return empty($this->token_expires) || strtotime($this->token_expires) < strtotime("now"); } /** * Getter for user avatar * @return string|null avatar */ protected function _getAvatar() { $avatar = null; if (!empty($this->_properties['social_accounts'][0])) { $avatar = $this->_properties['social_accounts'][0]['avatar']; } return $avatar; } /** * Generate token_expires and token in a user * @param string $tokenExpiration new token_expires user. * * @return void */ public function updateToken($tokenExpiration) { $expires = new DateTime(); $expires->modify("+ $tokenExpiration secs"); $this->token_expires = $expires; $this->token = str_replace('-', '', Text::uuid()); } }