/** Method to get information about the logged in user @param void @return view */ public function userList() { if (!Auth::check()) { return Redirect::to('/'); } $message = ''; if (Request::isMethod('post')) { $data = Input::except('_token'); $password = Hash::make(Input::get('password')); $user = new User(); $user->name = Input::get('name'); $user->email = Input::get('email'); $user->password = $password; $username = Input::get('name'); $userEmail = Input::get('email'); if ($user->save()) { try { Mail::send('emails.welcome', ['userEmail' => $username], function ($m) use($userEmail, $username) { $m->to($userEmail, $username)->subject('Express Rental'); }); } catch (Exception $ex) { } $message = 'Added Successfully'; return Redirect::to('/users/list')->with('message', $message); } else { $message = 'Addition not Successfully'; return Redirect::to('/users/list')->withErrors('message', $message); } } else { $allUserInfo = DB::table('users')->orderBy('users.id', 'DESC')->paginate(5); return view('Home.list')->with(compact('allUserInfo')); } }
/** * @testdox Requesting a password reminder adds an item to the Mail Queue. * @test */ public function emailReminder() { $user = new User(['username' => 'test']); $user->save(); $user->sendPasswordReminder(); $this->assertEquals(1, QueuedEmail::count()); }
/** * Store a newly created resource in storage. * * @param Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $user = new User($request->all()); $user->email = $user->account . env('DOMAIN'); $user->password = bcrypt($user->password); $user->save(); return $this->redirectWithSuccessFlash('user', "您已經新增了使用者<b>{$user->username}</b>"); }
/** * Create and save a new user. * * @param array */ public function create() { // Validate input $params = array('username' => $this->app->request->post('username'), 'email_address' => $this->app->request->post('email_address'), 'password_hash' => Password::hash($this->app->request->post('password'))); $user = new User($params); $user->save(); $this->app->redirectTo('home'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(StoreRequest $request) { // $users = new User(); $users->fill(['name' => $request->name, 'email' => $request->email]); //var_dump($users); die; $users->save(); return redirect()->action('UserController@index'); }
/** * Saves a user in the database. * * @param string $name * @param string $username * @param string $password * @param string $role * * @return Response */ public static function save($name, $username, $password, $role) { $user = new User(); $user->name = $name; $user->username = $username; $user->password = $password; $user->role = $role; $user->save(); }
public function registerUser($name, $email, $password) { $user = new User(); $user->password = is_null($password) ? null : bcrypt($password); $user->email = $email; $user->save(); $profile = new Profile(); $profile->name = $name; $profile->user_id = $user->id; $profile->description = ""; $profile->save(); return $user; }
public function userData($userData, $userId) { $user = User::find($userId); //Check if user exist if (!$user) { $user = new User(); } $user->name = $userData['name']; $user->email = $userData['email']; $user->password = Hash::make($userData['password']); $user->save(); return $user; }
public function postRegister(Request $request) { $time = time(); $user = new UserModel(); $user->usr_name = $request->input('usr_name'); $user->usr_email = $request->input('usr_email'); $user->usr_password = Hash::make($request->input('usr_password')); $user->usr_access_token = md5(uniqid($time, $request->input('usr_email'))); $user->usr_reset_token = md5(uniqid($time, $request->input('usr_email'))); $user->usr_active_fg = true; $user->rol_id = 1; if (!$user->save()) { return 'error'; } }
/** * Register an account * POST * * @param Request $request * @return Response */ public function register(Request $request) { $this->validate($request, ['login' => 'required|min:5|alpha_num|unique:accounts,account', 'password' => 'required|min:4', 'mail' => 'required|email', 'username' => 'required|alpha_num|unique:accounts,pseudo', 'question' => 'required', 'answer' => 'required', 'cu' => 'required', 'rules' => 'required']); $user = new UserManager(); $user->account = $request->login; $user->pass = $request->password; $user->email = $request->mail; $user->pseudo = $request->username; $user->level = 0; $user->question = $request->question; $user->reponse = $request->answer; $user->code = $this->_generateCode(24); $user->save(); Auth::login($user); return redirect()->route('join'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $validator = Validator::make($request->all(), ['first_name' => 'required|alpha|max:255', 'last_name' => 'required|alpha|max:255', 'email' => 'required|email|unique:users|max:255', 'password' => 'required|min:6']); if ($validator->fails()) { return Redirect::to(route('user.create'))->withErrors($validator)->withInput(); } else { $user = new User(); $user->first_name = $request->first_name; $user->last_name = $request->last_name; $user->email = $request->email; $user->password = bcrypt($request->password); $user->save(); Session::flash('info', 'Successfully created'); return Redirect::to(route('user.index')); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request, Guard $auth) { $v = \Validator::make($request->all(), ['email' => 'required|email', 'username' => 'required|max:255', 'password' => 'required|confirmed']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors()); } $user = new User(); if (User::whereEmail($request->input('email'))->count() < 1 && User::whereUsername($request->input('username'))->count() < 1) { $user->username = $request->input('username'); $user->email = $request->input('email'); $user->password = \Hash::make($request->input('password')); if ($user->save()) { \Auth::login($user); return redirect()->route('tasks.index'); } } return redirect()->back()->with("NOTIF_INFO", "Email or Username have been registered"); }
function register(Request $request) { $name = $request->input('name'); $email = $request->input('email'); $password = sha1($request->input('password')); $exist_user = User::where('email', $email)->count(); if ($exist_user == 0) { $user = new User(); $user->name = $name; $user->email = $email; $user->password = $password; $user->save(); $result = array('success' => true, 'message' => 'register success.'); } else { $result = array('success' => false, 'message' => 'email is existing.'); } return $result; }
public static function register($postData) { $user = User::where('email', $postData['email'])->first(); if ($user) { return false; } else { $postData['password'] = md5($postData['password']); unset($postData['retype']); $newUser = new User(); foreach ($postData as $key => $value) { $newUser->{$key} = $value; } $newUser->save(); unset($newUser['password']); return $newUser; } return false; }
public function registerSaveAction($request, $response) { $this->validator->rule('required', ['username', 'email', 'password', 'first_name', 'last_name']); $this->validator->rule('email', 'email'); if ($this->validate()) { $input = $request->getParsedBody(); $user = new User(); $user->username = $input['username']; $user->email = $input['email']; $user->password = password_hash($input['password'], PASSWORD_DEFAULT); $user->first_name = $input['first_name']; $user->last_name = $input['last_name']; $save = $user->save(); if ($save) { $this->flash->addMessage('success', 'Register Success'); } } return $response->withRedirect($this->router->pathFor('registerPage')); }
/** * @param array $params * @param null $request * @return array */ private function getParamsTwig($params = array(), $request = null) { if ($this->loginUrlOrGraphUser instanceof GraphUser) { $graphUser = $this->loginUrlOrGraphUser; // Create and update user $user = User::firstOrCreate(['facebook_id' => $graphUser->getId()]); if (!$user instanceof User) { $user = new User(); $user->facebook_id = $graphUser->getId(); } $user->gender = $graphUser->getGender() == 'male' ? 'M.' : 'Mme'; $user->email = $graphUser->getEmail(); $user->first_name = $graphUser->getFirstName(); $user->last_name = $graphUser->getLastName(); $user->save(); } $configFacebook = $this->config['facebook']; return array_merge(['APP_ID' => $configFacebook['id'], 'URL_WEB_APP' => $configFacebook['url'], 'user' => isset($graphUser) ? $graphUser : null], $params); }
public function postRegister(request $request) { $rules = array('number' => 'required|alpha|min:2|unique:users', 'name' => 'required|alpha|min:2', 'password' => 'required|alpha_num|between:6,8|confirmed', 'password_confirmation' => 'required|alpha_num|between:6,8'); $validator = Validator::make($request->all(), $rules); if ($validator->passes()) { $user = new User(); $user->number = $request['number']; $user->name = $request['name']; $user->phone = $request['phone']; $user->industry = $request['industry']; $user->company = $request['company']; $user->address = $request['address']; $user->qq = $request['qq']; $user->email = $request['email']; $user->cnumber = $request['cnumber']; $user->password = Hash::make($request['password']); $user->save(); return Redirect::to('auth/login')->with('message', '注册成功,立即登录体验!'); } else { return Redirect::to('/dream')->withErrors($validator)->with('message', '请您正确填写下列数据'); } }
/** * Add action method * * @return void */ public function add($rid = null) { $this->prepareView('users/add.phtml'); $this->view->title = 'Add User'; if (null !== $rid) { $role = new Model\Role(); $role->getById($rid); $this->view->title .= ' : ' . $role->name; $fields = $this->application->config()['forms']['App\\Form\\User']; $fields[1]['password1']['required'] = true; $fields[1]['password2']['required'] = true; $fields[0]['role_id']['value'] = $rid; unset($fields[0]['clear_logins']); unset($fields[0]['failed_attempts']); $this->view->form = new Form\User($fields); if ($this->request->isPost()) { $this->view->form->addFilter('strip_tags')->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($this->request->getPost()); if ($this->view->form->isValid()) { $this->view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8'])->filter(); $user = new Model\User(); $user->save($this->view->form->getFields(), $this->application->config()['application_title']); $this->view->id = $user->id; $this->sess->setRequestValue('saved', true); $this->redirect('/users/edit/' . $user->id); } } } else { $this->view->roles = (new Model\Role())->getAll(); } $this->send(); }
public function registerPost(Request $request, Response $response, $args) { $email = Input::post('email'); $username = Input::post('username'); $password = Input::post('password'); $passwordConfirm = Input::post('password_confirm'); $v = new Validator(new User()); $v->validate(['email' => [$email, 'required|email|uniqueEmail'], 'username' => [$username, 'required|alnumDash|max(20)|uniqueUsername'], 'password' => [$password, 'required|min(6)'], 'password_confirm' => [$passwordConfirm, 'required|matches(password)']]); if ($v->passes()) { $user = new User(); $user->email = $email; $user->username = $username; $user->password = $this->hash->password($password); $user->group_id = 3; $user->save(); $flash = "You have been registered."; } else { $flash = "registration failed."; } $this->view->render($response, 'register.twig', ['errors' => $v->errors(), 'flash' => $flash, 'request' => $request]); return $response; }
/** * @param User $user * @return null|string */ private function getTempPassword($user) { $arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'); $password = ""; for ($i = 0; $i < 32; $i++) { $password .= $arr[rand(0, count($arr) - 1)]; } $user->recover_passw = md5($password); $user->save(); if ($user->loaded()) { return $password; } return null; }
protected function users() { if (!Schema::hasTable('users')) { $this->info("Creating 'users' table."); Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name')->nullable(); $table->string('username')->unique(); $table->string('email')->nullable(); $table->string('password', 60); $table->string('password_reminder', 100)->nullable(); $table->rememberToken(); $table->timestamps(); }); } if (User::count() == 0) { $this->info("No users found; creating 'admin'."); $adminUser = new User(); $adminUser->username = '******'; $adminUser->name = 'Administrator'; $adminUser->password = bcrypt('admin'); $adminUser->email = config('app.site_email'); $adminUser->save(); } if (!Schema::hasTable('roles')) { $this->info("Creating 'roles' table."); Schema::create('roles', function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->timestamps(); }); } if (!Role::find(Role::ADMIN)) { $this->info("Creating admin role."); Role::firstOrCreate(['id' => Role::ADMIN, 'name' => trans_choice('roles.admin', 1)]); } $managerRole = Role::find(Role::MANAGER); if (!$managerRole) { $this->info("Creating manager role."); Role::firstOrCreate(['id' => Role::MANAGER, 'name' => trans_choice('roles.manager', 1)]); } $clerkRole = Role::find(Role::CLERK); if (!$clerkRole) { $this->info("Creating clerk role."); Role::firstOrCreate(['id' => Role::CLERK, 'name' => trans_choice('roles.clerk', 1)]); } if (!Schema::hasTable('role_user')) { $this->info("Creating 'role_user' table."); Schema::create('role_user', function (Blueprint $table) { $table->integer('user_id')->unsigned(); $table->foreign('user_id')->references('id')->on('users'); $table->integer('role_id')->unsigned(); $table->foreign('role_id')->references('id')->on('roles'); $table->primary(['user_id', 'role_id']); }); } // If there are no administrators, make the first user an admin. $adminRole = Role::find(Role::ADMIN); if (count(User::administrators()) === 0) { $adminUser = User::first(); $this->info("Making " . $adminUser->name . " an Administrator."); $adminUser->roles()->save($adminRole); } if (!Schema::hasTable('unavailability_types')) { $this->info("Creating 'unavailability_types' table."); Schema::create('unavailability_types', function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->string('background_colour'); $table->string('colour'); }); } if (!Schema::hasTable('user_unavailabilities')) { $this->info("Creating 'user_unavailabilities' table."); Schema::create('user_unavailabilities', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id')->unsigned()->nullable(); $table->foreign('user_id')->references('id')->on('users'); $table->date('start_date')->nullable(); $table->date('end_date')->nullable(); $table->integer('type_id')->unsigned()->nullable(); $table->foreign('type_id')->references('id')->on('unavailability_types'); $table->timestamps(); }); } if (!Schema::hasTable('queued_emails')) { $this->info("Creating 'queued_emails' table."); Schema::create('queued_emails', function (Blueprint $table) { $table->increments('id'); $table->integer('recipient_id')->unsigned()->nullable(); $table->foreign('recipient_id')->references('id')->on('users'); $table->string('subject'); $table->string('template'); $table->text('data'); $table->timestamps(); }); } }
/** * Add action method * * @return void */ public function add() { $roleId = $this->getRoleId(); $username = ''; $email = null; $role = new Model\Role(); $role->getById($roleId); $this->console->write(); $dupeUser = Table\Users::findBy(['username' => $username]); while ($username == '' || isset($dupeUser->id)) { if (isset($dupeUser->id)) { $this->console->write($this->console->colorize('That username already exists.', Console::BOLD_RED)); $username = ''; } if ($role->email_as_username) { while (!(new Email())->evaluate($username)) { $username = $this->console->prompt('Enter Email: '); } $email = $username; } else { while ($username == '') { $username = $this->console->prompt('Enter Username: '******''; while (!(new Email())->evaluate($email)) { $email = $this->console->prompt('Enter Email: '); } } } $dupeUser = Table\Users::findBy(['username' => $username]); } $password = ''; while ($password == '') { $password = $this->console->prompt('Enter Password: '******''; while (strtolower($active) != 'y' && strtolower($active) != 'n') { $active = $this->console->prompt('Active? (Y/N): '); } $verified = ''; while (strtolower($verified) != 'y' && strtolower($verified) != 'n') { $verified = $this->console->prompt('Verified? (Y/N): '); } $fields = ['role_id' => $roleId, 'username' => $username, 'password1' => $password, 'email' => $email, 'active' => strtolower($active) == 'y' ? 1 : 0, 'verified' => strtolower($verified) == 'y' ? 1 : 0]; $user = new Model\User(); $user->save($fields, $this->application->config()['application_title']); $this->console->write(); $this->console->write($this->console->colorize('User Added!', Console::BOLD_GREEN)); }