Пример #1
1
 /**
  * The register method is responsible for checking/validating
  * the given input (email and password) and either return an error code or
  * create a new user.
  *
  * @return mixed
  */
 public function register()
 {
     $validateUser = $this->validateUser();
     if ($validateUser->status == 'error') {
         return \Response::json($validateUser);
     } else {
         //All's good, create a new user
         $user = User::create(['name' => \Request::get('name'), 'email' => \Request::get('email'), 'password' => bcrypt(\Request::get('password'))]);
         if (!\Request::has('role')) {
             $role['role'] = 'mobile';
         } else {
             $role['role'] = 'web';
         }
         //assign role to user
         $role = Role::where('name', $role)->first();
         $user->roles()->save($role);
         $device = $this->sanitizeDevice($user->id);
         $this->deviceService->store($user->id, $device);
         //Retrieve the JWT and send back to the Controller
         $token = \JWTAuth::fromUser($user);
         $response = new ApiResponse();
         $response->status = 'success';
         $response->message = ['token' => $token];
     }
     return \Response::json($response);
 }
Пример #2
0
 public function createWithRandomPassword($attributes = [])
 {
     $attributes['password'] = Hash::make(str_random());
     $user = $this->user->create($attributes);
     $this->emailPasswordReset($user->email, function ($message) {
         $message->newUser = true;
     });
     return $user;
 }
Пример #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $this->validate($request, ['email' => 'required|email|unique:users', 'password' => 'required|min:6', 'password_confirm' => 'required|same:password'], ['email.required' => 'Поле email не заполнено', 'email.email' => 'Введите верный email', 'email.unique' => 'Такой email уже существует!', 'password.required' => 'Задайте пароль', 'password.min' => 'Пароль должен быть длиной не менее 6 символов', 'password_confirm.required' => 'Введите подтверждение пароля', 'password_confirm.same' => 'Подтверждение пароля введено не верно']);
     $input = $request->all();
     $user = $this->users->create($input);
     $user->password = bcrypt($input['password']);
     $user->save();
     return redirect()->route('admin.user.index')->with('messages', array('Пользователь успешно создан'));
 }
Пример #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $email = $this->ask('What is the email for the new super user: '******'What is the new super user\'s password: '******'email' => $email, 'password' => Hash::make($password)];
     if ($this->confirm("Are you sure you want to create a new user for {$email}? [yes|no]", false)) {
         $user = $this->user->create($attrs);
         $user->ensureRole('admin');
         $this->info("User created for email {$email} with id {$user->id}");
     }
 }
Пример #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role = Role::select('id')->where('name', '=', 'admin')->first();
     $user = User::create(['name' => 'Administrador', 'lastname' => 'Administrador', 'email' => '*****@*****.**', 'password' => bcrypt('admin'), 'dni' => '34785999', 'state_id' => '12', 'city_id' => '228', 'role_id' => $role->id, 'active' => '1']);
     $role = Role::select('id')->where('name', '=', 'user')->first();
     $user = User::create(['name' => 'User', 'lastname' => 'User', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'dni' => '34785998', 'state_id' => '12', 'city_id' => '228', 'role_id' => $role->id, 'active' => '1']);
 }
Пример #6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // ADMIN USER (DIMIZAS)
     User::create(array('name' => 'Christos', 'lastname' => 'Dimizas', 'email' => '*****@*****.**', 'password' => Hash::make('1234qwer'), 'user_role_id' => 1, 'user_subrole_id' => null, 'activation_status' => 1, 'is_deactivated' => 0));
     // ADMIN USER (IASONIDIS)
     User::create(array('name' => 'Theodoros', 'lastname' => 'Iasonidis', 'email' => '*****@*****.**', 'password' => Hash::make('!1234qwer!'), 'user_role_id' => 1, 'user_subrole_id' => null, 'activation_status' => 1, 'is_deactivated' => 0));
 }
Пример #7
0
 public function create($requestData)
 {
     $settings = Settings::first();
     $password = bcrypt($requestData->password);
     $role = $requestData->roles;
     $department = $requestData->departments;
     $companyname = $settings->company;
     if ($requestData->hasFile('image_path')) {
         if (!is_dir(public_path() . '/images/' . $companyname)) {
             mkdir(public_path() . '/images/' . $companyname, 0777, true);
         }
         $settings = Settings::findOrFail(1);
         $file = $requestData->file('image_path');
         $destinationPath = public_path() . '/images/' . $companyname;
         $filename = str_random(8) . '_' . $file->getClientOriginalName();
         $file->move($destinationPath, $filename);
         $input = array_replace($requestData->all(), ['image_path' => "{$filename}", 'password' => "{$password}"]);
     } else {
         $input = array_replace($requestData->all(), ['password' => "{$password}"]);
     }
     $user = User::create($input);
     $user->roles()->attach($role);
     $user->department()->attach($department);
     $user->save();
     Session::flash('flash_message', 'User successfully added!');
     //Snippet in Master.blade.php
     return $user;
 }
Пример #8
0
 public function postForm(FormAdminRequest $request)
 {
     try {
         $dataAdmin = $request->all();
         $password = $request->get('password', null);
         if (isset($dataAdmin['id']) && $dataAdmin['id'] != '') {
             $data = $request->except(array('password'));
             $runtime = User::find($dataAdmin['id']);
             $runtime->fill($data);
             $runtime->password = $runtime->password;
             if (!empty($password)) {
                 $runtime->password = Hash::make($password);
             }
             $runtime->save();
             $msg = 'Usuario Editado!';
         } else {
             $role = Role::whereName(User::ROL_CONTENIDO_ADMIN)->first();
             $dataAdmin['password'] = Hash::make($password);
             $NewUser = User::create($dataAdmin);
             $msg = 'Usuario Guardado!';
             RoleUser::create(['user_id' => $NewUser->id, 'role_id' => $role->id]);
         }
         return redirect(action('Admin\\AdminController@getIndex'))->with('messageSuccess', $msg);
     } catch (Exception $exc) {
         dd($exc->getMessage());
     }
 }
Пример #9
0
 /**
  * Run the database seeds.
  */
 public function run()
 {
     User::create($this->getUserDetails() + ['is_admin' => true]);
     if (!app()->runningUnitTests()) {
         $this->command->info('Admin user created. You can (and should) remove the auth details from .env now.');
     }
 }
Пример #10
0
 public function run()
 {
     $this->command->info('Running UserTableSeeder');
     Eloquent::unguard();
     $account = Account::create(['name' => 'Test Account', 'account_key' => str_random(16), 'timezone_id' => 1]);
     User::create(['email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD)]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 30) as $index) {
         User::create(['first_name' => $faker->firstName(), 'last_name' => $faker->lastName(), 'email' => $faker->email(), 'password' => bcrypt('secret'), 'hourly_rate' => $faker->numberBetween(25, 250)]);
     }
 }
Пример #12
0
 /**
  * Create new account
  *
  * @param Request $request
  * @return Response
  */
 public function postUser(Request $request)
 {
     if (!$this->appKeyAvailable($request)) {
         return $this->notAuthorized($request);
     }
     $validator = Validator::make($request->all(), ['username' => 'required|unique:users,username|min:4|max:32', 'email' => 'required|unique:users,email|max:32|email', 'password' => 'required|min:6']);
     if ($validator->fails()) {
         $this->setResultError($validator->messages(), 400);
     } else {
         $user = $request->all();
         $user['password'] = Hash::make($user['password']);
         $this->user = User::create($user);
         if (isset($user['profile'])) {
             if (is_array($user['profile'])) {
                 foreach ($user['profile'] as $key => $value) {
                     Profile::create(['key' => $key, 'value' => $value, 'user_id' => $this->user->id]);
                 }
             }
         }
         $this->setResultOk();
         $this->setSessionHash();
         $this->setUserData();
     }
     return $this->setResponse();
 }
Пример #13
0
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     DB::table('permission_role')->truncate();
     DB::table('role_user')->truncate();
     DB::table('users')->truncate();
     DB::table('roles')->truncate();
     DB::table('permissions')->truncate();
     DB::table('permission_groups')->truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     $faker = Faker\Factory::create();
     //User
     $admin = User::create(['email' => '*****@*****.**', 'name' => '管理员', 'password' => bcrypt('adminadmin')]);
     $test_user = User::create(['email' => '*****@*****.**', 'name' => '测试用户', 'password' => bcrypt('testtest')]);
     //Roles
     $role_admin = Role::create(['name' => 'admin', 'display_name' => '管理员']);
     $role_editor = Role::create(['name' => 'editor', 'display_name' => '编辑']);
     $role_user = Role::create(['name' => 'user', 'display_name' => '普通用户']);
     //Permission&PermissionGroup
     PermissionGroup::create(['name' => '后台']);
     PermissionGroup::create(['name' => 'RBAC', 'parent_id' => 1]);
     Permission::create(['name' => 'dashboard_view', 'display_name' => '首页', 'group_id' => 1]);
     $models = [['route_name' => 'users', 'menu_name' => '帐户', 'group_id' => 3, 'group_pid' => 2], ['route_name' => 'roles', 'menu_name' => '角色', 'group_id' => 4, 'group_pid' => 2], ['route_name' => 'permissions', 'menu_name' => '权限', 'group_id' => 5, 'group_pid' => 2], ['route_name' => 'permissiongroups', 'menu_name' => '权限分组', 'group_id' => 6, 'group_pid' => 2], ['route_name' => 'articles', 'menu_name' => '文章', 'group_id' => 7, 'group_pid' => 1], ['route_name' => 'settings', 'menu_name' => '配置', 'group_id' => 8, 'group_pid' => 1]];
     foreach ($models as $key => $model) {
         PermissionGroup::create(['name' => $model['menu_name'], 'parent_id' => $model['group_pid']]);
         Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_view', 'display_name' => $model['menu_name'] . '菜单']);
         Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_create', 'display_name' => '新建' . $model['menu_name']]);
         Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_update', 'display_name' => '修改' . $model['menu_name']]);
         Permission::create(['group_id' => $model['group_id'], 'name' => $model['route_name'] . '_delete', 'display_name' => '删除' . $model['menu_name']]);
     }
     //Roles Users
     $test_user->roles()->save($role_editor);
     //Roles Users
     // $role_admin->givePermissionTo($permission_admin_user);
 }
Пример #14
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     if ($data['user_role_id'] != 2) {
         return User::create(['name' => $data['name'], 'lastname' => $data['lastname'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'user_role_id' => $data['user_role_id'], 'activation_status' => 0, 'is_deactivated' => 0]);
     }
     return User::create(['name' => $data['name'], 'lastname' => $data['lastname'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'user_role_id' => $data['user_role_id'], 'user_subrole_id' => $data['user_subrole_id'], 'activation_status' => 0, 'is_deactivated' => 0]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:6']);
     $data = $request->input();
     User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     return redirect('/users')->withMessage('<i class="glyphicon glyphicon-ok"></i> This user has been created');
 }
Пример #16
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::create(['id' => 1, 'email' => '*****@*****.**', 'password' => \Hash::make('123456'), 'name' => 'Airton Filho', 'status_level' => 1]);
     User::create(['id' => 2, 'email' => '*****@*****.**', 'password' => \Hash::make('123456'), 'name' => 'Rafael Froes', 'status_level' => 1]);
     Score::create(['user_id' => 1, 'value' => 29384]);
     Score::create(['user_id' => 2, 'value' => 29384]);
 }
Пример #17
0
 public function store(Request $request)
 {
     $user_data = $this->collectUserFormData($request);
     $user = new User();
     $user_model = $user->create($user_data);
     return $user_model;
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 20) as $index) {
         User::create(['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'phone' => $faker->phoneNumber, 'county_id' => $faker->numberBetween($min = 3, $max = 4), 'town' => $faker->city, 'home_address' => $faker->streetAddress, 'email' => $faker->email, 'password' => Hash::make('123456789'), 'confirmed' => 1]);
     }
 }
Пример #19
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(\App\Http\Requests\CreateUserRequest $request)
 {
     $user = \App\Models\User::create($request->all());
     $user->password = bcrypt($user->password);
     $user->save();
     return redirect('users/' . $user->id);
 }
Пример #20
0
 public function store(LoginAlternativeRequest $request)
 {
     try {
         $credentials['password'] = $request->input('idfacebook');
         $credentials['email'] = $request->input('email');
         $data['tokendevice'] = $request->input('tokendevice');
         $data['typedevice'] = $request->input('typedevice');
         $datauser = User::whereEmail($credentials['email'])->get()->first();
         if (isset($datauser)) {
             if ($datauser->flagactive == User::STATE_USER_INACTIVE) {
                 $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, [], [], 'usuario Inactivo');
                 $this->_responseWS->response();
             }
         } else {
             $data = $request->all();
             $data['password'] = Hash::make($data['idfacebook']);
             $obj = User::create($data);
             $datosRol = Role::whereName('user_app')->first();
             $daoUserRol['role_id'] = (int) $datosRol->id;
             $daoUserRol['user_id'] = $obj->id;
             RoleUser::create($daoUserRol);
         }
         $this->login($request->all());
     } catch (\Exception $exc) {
         dd($exc->getMessage());
         $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, [], [], '');
     }
     $this->_responseWS->response();
 }
Пример #21
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::create(['name' => 'admin01', 'email' => '*****@*****.**', 'password' => bcrypt('admin01'), 'is_admin' => true, 'is_active' => true]);
     User::create(['name' => 'founder01', 'email' => '*****@*****.**', 'password' => bcrypt('founder01'), 'is_founder' => true, 'is_active' => true]);
     User::create(['name' => 'investor01', 'email' => '*****@*****.**', 'password' => bcrypt('investor01'), 'is_investor' => true, 'is_active' => true]);
     factory('App\\Models\\User', 10)->create();
 }
Пример #22
0
 /**
  * Run the database seeds.
  */
 public function run()
 {
     $users = [['name' => 'Despark Admin', 'email' => '*****@*****.**', 'password' => bcrypt('Despark1234')]];
     foreach ($users as $user) {
         User::create($user);
     }
 }
Пример #23
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['email' => 'required|email|unique:users', 'password' => 'required|min:8']);
     $data = ['name' => $request->input('name'), 'email' => $request->input('email'), 'password' => Hash::make($request->input('password'))];
     User::create($data);
     return redirect()->route('admin.user.index')->with('success', 'Successfully created!');
 }
Пример #24
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\UserCreationRequest $request)
 {
     $admin = User::create($request->all());
     $admin->password = Hash::make($request->input('password'));
     $admin->save();
     return redirect('login');
 }
 public function install(Requests\PostInstallationRequest $request)
 {
     $data = $request->all();
     $data['password'] = Hash::make($data['password']);
     $user = User::create($data);
     return redirect()->action('DashboardController@index')->with('success', 'Installation has been completed');
 }
Пример #26
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     Role::create(['title' => 'Administrator', 'slug' => 'admin']);
     User::create(['username' => 'Gazpar Gloria', 'email' => '*****@*****.**', 'password' => bcrypt('GGGCI*16'), 'seen' => true, 'role_id' => 1, 'confirmed' => true]);
     User::create(['username' => 'Leonardo Balderas', 'email' => '*****@*****.**', 'password' => bcrypt('LBGCI*16'), 'seen' => true, 'role_id' => 1, 'valid' => true, 'confirmed' => true]);
 }
Пример #27
0
 /**
  * Find or create a user.
  *
  * @param  \Laravel\Socialite\One\User|\Laravel\Socialite\Two\User  $user
  * @param  string                                                   $provider
  *
  * @return \Arcanesoft\Contracts\Auth\Models\User
  */
 private function findOrCreateUser($user, $provider)
 {
     if ($authUser = User::where('social_provider_id', $user->id)->first()) {
         return $authUser;
     }
     return User::create(['name' => $user->name, 'email' => $user->email, 'social_provider' => $provider, 'social_provider_id' => $user->id]);
 }
Пример #28
0
    public function postSignUp(Request $request)
    {
        $this->validate($request, ['email' => 'required|unique:users|email|max:255', 'username' => 'required|unique:users|alpha_dash|max:20', 'password' => 'required|min:6']);
        User::create(['email' => $request->input('email'), 'username' => $request->input('username'), 'password' => bcrypt($request->input('password'))]);
        return redirect()->route('home')->with('info', 'Your account is created. You can now sign in!
			');
    }
Пример #29
0
 /**
  * Store a newly created resource in storage.
  *
  * @param AdduserRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(AdduserRequest $request)
 {
     //        $input = $request->all();                               // get all data
     //        $input['confirmed'] = 1;                                // set confirmed to 1
     //        $input['password'] = Hash::make($input['password']);    // hash password
     //
     //        $user       =   User::create($input);                   // save above details
     $user = User::create(['first_name' => $request->first_name, 'last_name' => $request->last_name, 'email' => $request->email, 'confirmed' => 1, 'password' => Hash::make($request->password)]);
     //        $profile    =   $user->profile()->save(new Profile);    // also create new profile
     //        $profile->apartment_id  =   Auth::user()->profile->defaultApartment; // get current defaultApartment
     //        $profile->save();                                       // save details on profile
     $profile = Profile::create(['user_id' => $user->id, 'apartment_id' => Auth::user()->profile->defaultApartment]);
     dd(Auth::user()->profile->defaultApartment);
     $role = Role::whereName('user')->first();
     $user->assignRole($role);
     //Assign Role
     $block_no = $request->blockno;
     // get block_no from profileform
     $floor_no = $request->floorno;
     // get floor_no from profileform
     $profile->apartments()->attach($profile->defaultApartment, ['approved' => '1', 'block_no' => $block_no, 'floor_no' => $floor_no]);
     // attach this profile with default apartment, with approved = 1, and block_no, floor_no according to profileform in apartment_profile pivot table.
     Crm_account::create(['account' => $user->first_name . $user->last_name, 'fname' => $user->first_name, 'lname' => $user->last_name, 'company' => 'Company Name', 'email' => $user->email, 'address' => 'Current Address', 'city' => 'Nagpur', 'state' => 'Maharashtra', 'zip' => '440012', 'country' => 'India']);
     return redirect()->back()->withMessage('User has been Added')->withStatus('success');
 }
Пример #30
0
 public function testUserAdd()
 {
     $user = factory(User::class, 'valid-user')->make();
     $values = ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'email' => $user->email, 'username' => $user->username, 'password' => $user->password];
     User::create($values);
     $this->tester->seeRecord('users', $values);
 }