public static function insert($data) { try { $props = ['username' => $data['username'], 'email' => strtolower($data['email']), 'password' => Model_Service_Util::hash_password($data['password']), 'created_at' => date('Y-m-d H:i:s', Date::forge()->get_timestamp())]; $new = Model_User::forge($props); $new->save(); return $new->id; } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); return false; } }
public function post_update_password() { $val = Validation::forge(); $val->add_callable('MyRules'); $val->add_field('password', Lang::get('label.password'), 'required|valid_password|min_length[8]|max_length[50]'); $val->add_field('confirm_password', Lang::get('label.confirm_password'), 'match_field[password]'); if ($val->run()) { $props = array('password' => Model_Service_Util::hash_password($val->validated('password'))); if (Model_Base_User::update($this->user_id, $props)) { $this->data['success'] = Lang::get($this->controller . '.' . $this->action . '.success'); } else { $this->data['error'] = Lang::get($this->controller . '.' . $this->action . '.error'); } } else { $this->data['errors'] = $val->error_message(); } return $this->response($this->data); }
public static function add_user() { $user_props = ['username' => 'wjshop', 'email' => '*****@*****.**', 'password' => Model_Service_Util::hash_password('11111111'), 'group' => 100, 'customer_name' => 'wjshop', 'created_at' => date('Y-m-d H:i:s', Date::forge()->get_timestamp())]; $user = Model_User::forge($user_props); $user->save(); }