Beispiel #1
0
 /**
  * Stores new user
  *
  */
 public function postIndex()
 {
     //$this->user->terms = Input::get('terms');
     $this->user->username = Input::get('email');
     $this->user->email = Input::get('email');
     $password = Input::get('password');
     $passwordConfirmation = Input::get('password_confirmation');
     $this->user->pid = $this->keygen();
     if (!empty($password)) {
         if ($password === $passwordConfirmation) {
             $this->user->password = $password;
             // The password confirmation will be removed from model
             // before saving. This field will be used in Ardent's
             // auto validation.
             $this->user->password_confirmation = $passwordConfirmation;
         } else {
             // Redirect to the new user page
             return Redirect::to('user/create')->withInput(Input::except('password', 'password_confirmation'))->with('error', Lang::get('admin/users/messages.password_does_not_match'));
         }
     } else {
         unset($this->user->password);
         unset($this->user->password_confirmation);
     }
     // Save if valid. Password field will be hashed before save
     $this->user->save();
     if ($this->user->id) {
         DB::table('oauth_user_roles')->insert(array(array('user_id' => $this->user->pid, 'client_id' => 'http://govclient.nellcorp.com', 'role' => 'patient', 'created_at' => new DateTime(), 'updated_at' => new DateTime())));
         // Redirect with success message, You may replace "Lang::get(..." for your custom message.
         return Redirect::to('user/login')->with('notice', Lang::get('user/user.user_account_created'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('user/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
 /**
  * Stores new user
  *
  */
 public function postIndex()
 {
     $this->user->email = Input::get('email');
     $password = Input::get('password');
     $passwordConfirmation = Input::get('password_confirmation');
     if (!empty($password)) {
         if ($password === $passwordConfirmation) {
             $this->user->password = $password;
             // The password confirmation will be removed from model
             // before saving. This field will be used in Ardent's
             // auto validation.
             $this->user->password_confirmation = $passwordConfirmation;
         } else {
             // Redirect to the new user page
             return Redirect::to('user/create')->withInput(Input::except('password', 'password_confirmation'))->with('error', Lang::get('admin/users/messages.password_does_not_match'));
         }
     } else {
         unset($this->user->password);
         unset($this->user->password_confirmation);
     }
     // Save if valid. Password field will be hashed before save
     $this->user->save();
     if ($this->user->id) {
         // Redirect with success message, You may replace "Lang::get(..." for your custom message.
         return Redirect::to('user/login')->with('notice', Lang::get('user/user.user_account_created'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('user/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
 /**
  * Stores new account
  *
  */
 public function store()
 {
     // Validate the inputs
     $rules = array('username' => 'required|alpha_dash|unique:users,username', 'fullname' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'between:4,11|confirmed', 'password_confirmation' => 'between:4,11');
     $this->user->username = Input::get('username');
     $this->user->fullname = Input::get('fullname');
     $this->user->email = Input::get('email');
     $this->user->password = Input::get('password');
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $this->user->password_confirmation = Input::get('password_confirmation');
     $this->user->confirmed = Input::get('confirm');
     // Permissions are currently tied to roles. Can't do this yet.
     //$user->permissions = $user->roles()->preparePermissionsForSave(Input::get( 'permissions' ));
     // Save if valid. Password field will be hashed before save
     $this->user->save($rules);
     if ($this->user->id) {
         // Save roles. Handles updating.
         $this->user->saveRoles(Input::get('roles'));
         // Redirect to the new user page
         //return Redirect::to('users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
         return Redirect::to('admin/users')->with('success', Lang::get('admin/user/messages.create.success'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
Beispiel #4
0
 public function run()
 {
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->role = 'Admin';
     $user->password_confirmation = '1234';
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = true;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->username, (array) $user->errors());
     } else {
         Log::info('Created user "' . $user->username . '" <' . $user->email . '>');
     }
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->role = 'User';
     $user->password_confirmation = '1234';
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = true;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->username, (array) $user->errors());
     } else {
         Log::info('Created user "' . $user->username . '" <' . $user->email . '>');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $rules = array('displayname' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:4');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $this->user->displayname = Input::get('displayname');
         $this->user->email = Input::get('email');
         $this->user->password = Input::get('password');
         $this->user->password_confirmation = Input::get('password_confirmation');
         $this->user->confirmed = Input::get('confirm');
         $this->user->save();
         Event::fire('controller.user.create', array($this->user));
         if ($this->user->id) {
             $this->user->saveRoles(Input::get('roles'));
             $pro = Input::get('user_profiles');
             $profile = new UserProfile($pro['new']);
             $user = User::find($this->user->id);
             $user->profiles()->save($profile);
             Activity::log(array('contentID' => $this->user->id, 'contentType' => 'account_created', 'description' => $this->user->id, 'details' => 'account_created', 'updated' => Confide::user()->id ? true : false));
             return Api::to(array('success', Lang::get('admin/users/messages.create.success'))) ?: Redirect::to('admin/users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
         } else {
             return Api::to(array('error', $this->user->errors()->all())) ?: Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', $this->user->errors()->all());
         }
     } else {
         return Api::to(array('error', Lang::get('admin/users/messages.edit.error'))) ?: Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', Lang::get('admin/users/messages.edit.error'))->withErrors($validator);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $this->user->username = Input::get('username');
     $this->user->email = Input::get('email');
     $this->user->password = Input::get('password');
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $this->user->password_confirmation = Input::get('password_confirmation');
     $this->user->confirmed = Input::get('confirm');
     // Permissions are currently tied to roles. Can't do this yet.
     //$user->permissions = $user->roles()->preparePermissionsForSave(Input::get( 'permissions' ));
     // Save if valid. Password field will be hashed before save
     $this->user->save();
     if ($this->user->id) {
         // Save roles. Handles updating.
         $this->user->saveRoles(Input::get('roles'));
         // Redirect to the new user page
         return Redirect::to('admin/users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
 function updateProfile()
 {
     $input = Input::parse();
     if (Token::check($input['token'])) {
         $user = new User();
         $user->set(array('name' => $input['name'], 'username' => $input['username']));
         if (!$user->errors()) {
             $user->update();
             Session::flash('success', 'Successfully updated');
             Redirect::to('profile');
         } else {
             Session::flash('error', $user->errors());
             Redirect::to('profile');
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $this->user->displayname = Input::get('displayname');
     $this->user->email = Input::get('email');
     $this->user->password = Input::get('password');
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $this->user->password_confirmation = Input::get('password_confirmation');
     $this->user->confirmed = Input::get('confirm');
     // Save if valid. Password field will be hashed before save
     $this->user->save();
     if ($this->user->id) {
         // Save roles. Handles updating.
         $this->user->saveRoles(Input::get('roles'));
         $pro = Input::get('user_profiles');
         $profile = new UserProfile($pro['new']);
         $user = User::find($this->user->id);
         $user->profiles()->save($profile);
         // Redirect to the new user page
         return Redirect::to('admin/users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
 public function run()
 {
     $user = new User();
     $user->email = '*****@*****.**';
     $user->username = '******';
     $user->password = Hash::make('secret');
     $user->password_confirmation = $user->password;
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user "' . $user->email . '" <' . $user->email . '>');
     }
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     $user = new User();
     $user->email = '*****@*****.**';
     $user->username = '******';
     $user->password = Hash::make('secret');
     $user->password_confirmation = $user->password;
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user "' . $user->email . '" <' . $user->email . '>');
     }
     $user = User::where('username', $user->username)->firstOrFail();
     $user->attachRole($admin);
 }
 public function run()
 {
     $user = new User();
     $user->first_name = $_ENV['USER_FIRST_NAME'];
     $user->last_name = $_ENV['USER_LAST_NAME'];
     $user->username = $_ENV['USER_USERNAME'];
     $user->email = $_ENV['USER_EMAIL'];
     $user->password = $_ENV['USER_PASS'];
     $user->password_confirmation = $_ENV['USER_PASS'];
     $user->confirmed = 1;
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user ' . $user->email);
     }
     $guest = new User();
     $guest->first_name = $_ENV['GUEST_FIRST_NAME'];
     $guest->last_name = $_ENV['GUEST_LAST_NAME'];
     $guest->username = $_ENV['GUEST_USERNAME'];
     $guest->email = $_ENV['GUEST_EMAIL'];
     $guest->password = $_ENV['GUEST_PASS'];
     $guest->password_confirmation = $_ENV['GUEST_PASS'];
     $guest->confirmed = 1;
     $guest->confirmation_code = md5(uniqid(mt_rand(), true));
     if (!$guest->save()) {
         Log::info('Unable to create user ' . $guest->email, (array) $guest->errors());
     } else {
         Log::info('Created user ' . $guest->email);
     }
 }
 /**
  * Stores new account
  *
  */
 public function store()
 {
     $user = new User();
     $user->firstname = Input::get('firstname');
     $user->lastname = Input::get('lastname');
     $user->email = Input::get('email');
     $matches = explode("@", $user->email);
     $username = isset($matches[0]) ? $matches[0] : $user->firstname . '_' . $user->lastname;
     $username = preg_replace("/[^0-9a-zA-Z-]/", '', $username);
     $user->username = $username;
     $user->password = Input::get('password');
     $user->gender = Input::get('gender');
     $user->type = Input::has('type') ? Input::get('type') : 'dreamer';
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $user->password_confirmation = Input::get('password_confirmation');
     // Save if valid. Password field will be hashed before save
     $user->save();
     if ($user->id) {
         // Redirect with success message, You may replace "Lang::get(..." for your custom message.
         return Redirect::action('UserController@login')->with('notice', Lang::get('confide::confide.alerts.account_created'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $user->errors()->all(':message');
         return Redirect::action('UserController@create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
Beispiel #12
0
 /**
  * Stores new account
  *
  */
 public function store()
 {
     $user = new User();
     $user->first_name = Input::get('first_name');
     $user->last_name = Input::get('last_name');
     $user->username = Input::get('username');
     $user->email = Input::get('email');
     $user->password = Input::get('password');
     User::setRules('store');
     // Hacky workaround for: https://github.com/laravelbook/ardent/issues/152
     if (app()->env === 'testing') {
         unset(User::$rules['password_confirmation']);
         unset(User::$rules['password']);
     } else {
         $user->password_confirmation = Input::get('password_confirmation');
     }
     $user->save();
     if ($user->getKey()) {
         $notice = Lang::get('confide::confide.alerts.account_created') . ' ' . Lang::get('confide::confide.alerts.instructions_sent');
         $user->roles()->sync([6]);
         // Redirect with success message, You may replace "Lang::get(..." for your custom message.
         return Redirect::action('AuthController@login')->with('notice', $notice);
     } else {
         // Get validation errors (see Ardent package)
         $error = $user->errors()->all(':message');
         return Redirect::action('AuthController@create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
Beispiel #13
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $this->user->username = Input::get('username');
     $this->user->email = Input::get('email');
     $this->user->password = Input::get('password');
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $this->user->password_confirmation = Input::get('password_confirmation');
     $this->user->confirmed = Input::get('confirm');
     // Permissions are currently tied to roles. Can't do this yet.
     //$user->permissions = $user->roles()->preparePermissionsForSave(Input::get( 'permissions' ));
     // Save if valid. Password field will be hashed before save
     $this->user->engine_key = Hash::make(uniqid(mt_rand(), true));
     $this->user->save();
     try {
         // Register the user on the engine
         $return = xDockerEngine::register(array('username' => $this->user->username, 'password' => $this->user->engine_key));
         Log::info("Return Status : " . $return);
         EngineLog::logIt(array('user_id' => $this->user->id, 'method' => 'admin:register', 'return' => $return));
     } catch (Exception $e) {
         Log::error('Error while registering the user!' . $e->getMessage());
     }
     if ($this->user->id) {
         // Save roles. Handles updating.
         $this->user->saveRoles(Input::get('roles'));
         // Redirect to the new user page
         return Redirect::to('admin/users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
 public function run()
 {
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->password_confirmation = '@Password1';
     $user->confirmed = 1;
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->save();
     $profile = new Profile();
     $profile->user_id = $user->id;
     $profile->firstname = 'David';
     $profile->lastname = 'Hernandez';
     $profile->mobile = '(916)952-5736';
     $profile->dob = '09/24/1986';
     $profile->avatar = '/img/coach-avatar.jpg';
     $profile->save();
     if (!$user->id) {
         Log::info('Unable to create user ' . $user->username, (array) $user->errors());
     } else {
         Log::info('Created user "' . $user->username . '" <' . $user->email . '>');
     }
     $user1 = new User();
     $user1->username = '******';
     $user1->email = '*****@*****.**';
     $user1->password = '******';
     $user1->password_confirmation = '@Password1';
     $user1->confirmed = 1;
     $user1->confirmation_code = md5(uniqid(mt_rand(), true));
     $user1->save();
     $profile1 = new Profile();
     $profile1->user_id = $user1->id;
     $profile1->firstname = 'David';
     $profile1->lastname = 'Hernandez';
     $profile1->mobile = '(916)952-5736';
     $profile->dob = '09/24/1986';
     $profile1->avatar = '/img/coach-avatar.jpg';
     $profile1->save();
     if (!$user1->id) {
         Log::info('Unable to create user ' . $user1->username, (array) $user1->errors());
     } else {
         Log::info('Created user "' . $user1->username . '" <' . $user1->email . '>');
     }
     $admin = new Role();
     $admin->name = 'administrator';
     $admin->save();
     $club = new Role();
     $club->name = 'club owner';
     $club->save();
     $club2 = new Role();
     $club2->name = 'club administrator';
     $club2->save();
     $default = new Role();
     $default->name = 'default';
     $default->save();
     $user->attachRole($club);
     $user1->attachRole($default);
 }
Beispiel #15
0
 public function run()
 {
     Eloquent::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     // Roles
     DB::table('roles')->delete();
     Role::create(array('name' => 'Admin'));
     Role::create(array('name' => 'Manager'));
     Role::create(array('name' => 'Player'));
     // Users
     DB::table('users')->delete();
     // Admin
     $user = new User();
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->username = '******';
     $user->password_confirmation = 'Birdie002$';
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user ' . $user->email);
     }
     $userRole = DB::table('roles')->where('name', '=', 'Admin')->pluck('id');
     $user->roles()->attach($userRole);
     // Manager
     $user = new User();
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->username = '******';
     $user->password_confirmation = '1111';
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user ' . $user->email);
     }
     $userRole = DB::table('roles')->where('name', '=', 'Manager')->pluck('id');
     $user->roles()->attach($userRole);
     // Player
     $user = new User();
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->username = '******';
     $user->password_confirmation = '1111';
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user ' . $user->email);
     }
     $userRole = DB::table('roles')->where('name', '=', 'Player')->pluck('id');
     $user->roles()->attach($userRole);
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
Beispiel #16
0
 /**
  * Stores new user
  *
  */
 public function postIndex()
 {
     $rules = array('recaptcha_response_field' => 'required|recaptcha');
     $capchaValidator = Validator::make(Input::all(), $rules);
     if ($capchaValidator->passes()) {
         //input new users for a passing validator only
         $this->user->username = Input::get('username');
         $this->user->email = Input::get('email');
         $accountType = Input::get('Account_Type');
         if ($accountType == 1 && !(strpos($this->user->email, '@uoguelph') !== FALSE)) {
             return Redirect::to('user/create')->withInput(Input::except('password', 'password_confirmation'))->with('error', Lang::get('admin/users/messages.not_campus_domain'));
         }
         $password = Input::get('password');
         $passwordConfirmation = Input::get('password_confirmation');
         if (!empty($password)) {
             if ($password === $passwordConfirmation) {
                 $this->user->password = $password;
                 // The password confirmation will be removed from model
                 // before saving. This field will be used in Ardent's
                 // auto validation.
                 $this->user->password_confirmation = $passwordConfirmation;
             } else {
                 // Redirect to the new user page
                 return Redirect::to('user/create')->withInput(Input::except('password', 'password_confirmation'))->with('error', Lang::get('admin/users/messages.password_does_not_match'));
             }
         } else {
             unset($this->user->password);
             unset($this->user->password_confirmation);
         }
         // Save if valid. Password field will be hashed before save
         $this->user->save();
         if ($this->user->id) {
             // Redirect with success message, You may replace "Lang::get(..." for your custom message.
             return Redirect::to('user/login')->with('notice', Lang::get('user/user.user_account_created'));
         } else {
             // Get validation errors (see Ardent package)
             $error = $this->user->errors()->all();
             return Redirect::to('user/create')->withInput(Input::except('password'))->with('error', $error);
         }
     } else {
         return Redirect::to('user/create')->withInput(Input::except('password', 'password_confirmation'))->with('error', Lang::get('validation.recaptcha'));
     }
 }
 public static function handleRegister()
 {
     $params = $_POST;
     $user = new User(array('name' => $params['username'], 'password' => $params['password']));
     $errors = $user->errors();
     if (count($errors) == 0) {
         $user->save();
     } else {
         Redirect::to('/register', array('errors' => $errors));
     }
     Redirect::to('/login', array('message' => 'Käyttäjätunnus luotu onnistuneesti'));
 }
 public static function store()
 {
     $params = $_POST;
     $user = new User(array('name' => $params['name'], 'email' => $params['email'], 'password' => $params['password'], 'role_id' => $params['role_id']));
     $errors = $user->errors();
     if (count($errors) > 0) {
         // Todo error message
         Redirect::to('/users/create', array('errors' => $errors, 'attributes' => $params));
     }
     $user->save();
     Redirect::to('/users#' . $user->id);
 }
Beispiel #19
0
 public static function register($parameters)
 {
     $parameters['userlevel'] = 1;
     $user = new User($parameters);
     $errors = $user->errors();
     if (count($errors) == 0) {
         $user->save();
         $content["success"] = "Registeration complete.";
         return $content;
     } else {
         $content["errors"] = $errors;
         return $content;
     }
 }
Beispiel #20
0
 public function createUsersPlayersTest($nbPlayer = 2)
 {
     // Set Php Time Out
     ini_set('max_execution_time', 300);
     //300 seconds = 5 minutes
     // Suppression des Users & Players de Test
     $deletedUsers = User::where('email', 'LIKE', '%aa.be')->delete();
     // Boucle
     $createdUsers = 0;
     $messageRetour = '';
     for ($u = 1; $u <= $nbPlayer; $u++) {
         // 1-Auto Values
         $autoNom = 'Player-' . $u;
         $autoPrenom = 'player ' . $u;
         $autoMail = 'player_' . $u . '@aa.be';
         // 2-Create User with role = Player (3)
         $user = new User();
         $user->email = $autoMail;
         $user->password = '******';
         $user->username = $autoNom;
         $user->password_confirmation = '1111';
         $user->confirmation_code = md5(uniqid(mt_rand(), true));
         $user->confirmed = 1;
         if (!$user->save()) {
             $messageRetour .= 'Unable to create user ' . $user->email;
             $messageRetour .= print_r($user->errors());
             $messageRetour .= '<hr>';
         } else {
             $messageRetour .= $u . ' Created user ' . $user->email;
             $messageRetour .= '<hr>';
             $userRole = DB::table('roles')->where('name', '=', 'Player')->pluck('id');
             $user->roles()->attach($userRole);
             // 3-Create Player
             $userId = $user->id;
             $autoNation = rand(2, 4);
             $autoHcp = rand(0, 360) / 10;
             $autoLangue = rand(1, 3);
             $autoClub = rand(2, 7);
             $autosexe = rand(1, 2);
             $autoLicence = 'TEST' . $u;
             $year = rand(1950, 2006);
             $month = rand(1, 12);
             $day = rand(1, 28);
             Player::create(array('user_id' => $userId, 'nom' => $autoNom, 'prenom' => $autoPrenom, 'nation_id' => $autoNation, 'hcp' => $autoHcp, 'langue_id' => $autoLangue, 'club_id' => $autoClub, 'statusplayer_id' => 1, 'sexe_id' => $autosexe, 'naissance' => Carbon::createFromDate($year, $month, $day), 'licence' => $autoLicence));
             $createdUsers++;
         }
     }
     return $messageRetour;
 }
 public function run()
 {
     $user = new User();
     $user->email = '*****@*****.**';
     $user->username = '******';
     $user->password = '******';
     $user->password_confirmation = 'champion';
     $user->confirmation_code = md5(uniqid(mt_rand(), true));
     $user->confirmed = 1;
     if (!$user->save()) {
         Log::info('Unable to create user ' . $user->email, (array) $user->errors());
     } else {
         Log::info('Created user ' . $user->email);
     }
 }
 public static function handle_signup()
 {
     $params = $_POST;
     $user = new User(array('username' => $params['username'], 'password' => $params['password']));
     $errors = $user->errors();
     if (count($errors) > 0) {
         Redirect::to('/signup', array('errors' => $errors));
     }
     if ($user->check_username_exists()) {
         Redirect::to('/signup', array('errors' => array('Käyttäjätunnus on jo olemassa')));
     }
     $user->save();
     $_SESSION['user'] = $user->id;
     Redirect::to('/', array('message' => 'Tervetuloa takaisin ' . $user->username . '!'));
 }
 public static function store()
 {
     $attributes = self::get_attributes();
     $attributes['type'] = 'normal';
     $user = new User($attributes);
     $errors = $user->errors();
     if ($attributes['password'] != $attributes['password_validation']) {
         $errors[] = 'Salasana ja vahvistus eivät täsmää';
     }
     if (count($errors) == 0) {
         $user->register();
         self::login_and_redirect_to_home_page($user);
     } else {
         View::make('user/registration.html', array('errors' => $errors, 'attributes' => $attributes));
     }
 }
Beispiel #24
0
 function send_password()
 {
     $user_id = Request::param('id');
     if (!current_user()->is('admin')) {
         Response()->not_authorized();
     }
     if (!isset($user_id)) {
         Response('Invalid user id');
     }
     $user = new User($user_id);
     $result = $user->send_password();
     if ($user->validation_passed()) {
         Response($result);
     } else {
         Response()->error($user->errors());
     }
 }
 public static function store()
 {
     $params = $_POST;
     $kayttaja = $_POST['kayttajaid'];
     $sana1 = $_POST['salasana'];
     $kayttaja_admin = FALSE;
     $attributes = new User(array('kayttajaid' => $params['kayttajaid'], 'kayttajannimi' => $params['kayttajannimi'], 'salasana' => $params['salasana'], 'admin' => $kayttaja_admin));
     $kayttaja = new User($attributes);
     $errors = $kayttaja->errors();
     if (count($errors) == 0) {
         //Kayttaja on syötetty oikein!
         $kayttaja->save();
         Redirect::to('/login', array('message' => 'Käyttäjä on nyt rekisteröity. Kirjaudu sovellukseen.'));
     } else {
         Redirect::to('/kayttaja/rekisteroidy', array('errors' => $errors));
     }
 }
Beispiel #26
0
 /**
  * attempt to register user and redirect to home on success
  * or to login page if registration fails
  *
  * @return Illuminate\Http\RedirectResponse
  */
 public function register()
 {
     $user = new User();
     $user->username = e(Input::get('username'));
     $user->password = Input::get('password');
     $user->password_confirmation = Input::get('password_confirmation');
     $user->captcha = Input::get('captcha');
     if ($user->save()) {
         $info = Input::only('username', 'password');
         if (Auth::attempt($info)) {
             return Redirect::to('/');
         } else {
             return Redirect::to('/login')->withErrors(['message' => 'A general error occurred, please try again.'])->withInput();
         }
     } else {
         return Redirect::to('/login')->withErrors($user->errors())->withInput();
     }
 }
 public static function update()
 {
     self::get_user_logged_in();
     $params = $_POST;
     $attributes = array('username' => $_SESSION['user'], 'password' => $params['password'], 'password_confirm' => $params['password_confirm'], 'first_name' => $params['first_name'], 'sure_name' => $params['sure_name'], 'email' => $params['email']);
     if (isset($params['friends'])) {
         $attributes['friends'] = $params['friends'];
     }
     $user = new User($attributes);
     $errors = $user->errors();
     if (count($errors) === 1) {
         $user->update();
         Redirect::to('/catchList', array('message' => "Käyttäjätiedot päivitetty!"));
     } else {
         unset($errors[0]);
         $users = User::all_usernames();
         View::make('user/updateUser.html', array('errors' => $errors, 'attributes' => $attributes, 'users' => $users));
     }
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 50) as $index) {
         $user = new User();
         $user->username = $faker->userName() . $index;
         $user->email = $faker->email() . $index;
         $user->display_name = $user->username;
         $user->confirmed = true;
         $user->password = '******';
         $user->password_confirmation = 'admin';
         $user->confirmation_code = md5(uniqid(mt_rand(), true));
         if (!$user->save()) {
             Log::info('Unable to create user ' . $user->username, (array) $user->errors());
         } else {
             Log::info('Created user "' . $user->username . '" <' . $user->email . '>');
         }
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param $id
  * @throws \Acme\Core\Exceptions\EntityNotFoundException
  * @internal param $user
  * @return Response
  */
 public function update($id)
 {
     $user = $this->userRepository->findById($id);
     // Validate the inputs
     $val = $this->userRepository->getAdminEditForm($id);
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     if (!$this->userRepository->update($id, $val->getInputData())) {
         return Redirect::back()->with('errors', $this->userRepository->errors())->withInput();
     }
     $roles = is_array(Input::get('roles')) ? Input::get('roles') : [];
     $user->saveRoles($roles);
     // If user activate status have changed;
     if ($user->active != Input::get('active')) {
         $this->authService->changeActivateStatus($user);
     }
     return Redirect::action('AdminUsersController@index')->with('success', 'Updated user');
 }
 public static function update($id)
 {
     self::check_logged_in();
     $params = $_POST;
     if (isset($_POST['is_admin'])) {
         $attributes = array('id' => $id, 'name' => $params['name'], 'password' => $params['password'], 'is_admin' => 1);
     } else {
         $attributes = array('id' => $id, 'name' => $params['name'], 'password' => $params['password'], 'is_admin' => 0);
     }
     //Kint::dump($params);
     $user = new User($attributes);
     $errors = $user->errors();
     if (count($errors) > 0) {
         View::make('user/edit.html', array('errors' => $errors, 'attributes' => $attributes));
     } else {
         $user->update();
         Redirect::to('/user/' . $user->id, array('message' => 'Käyttäjää muokattu onnistuneesti'));
     }
 }