示例#1
0
 protected function _before()
 {
     $this->user = User::where('name', 'admin')->first();
     $fake = Factory::create();
     $password = bcrypt('password');
     $this->author = User::create(['name' => $fake->userName, 'email' => $fake->email, 'password' => $password]);
 }
 /**
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function save(Request $request)
 {
     $this->validate($request, ['password' => 'required|confirmed|min:3', 'password_old' => 'required|password']);
     $user = User::find(auth()->user()->id);
     $user->password = bcrypt($request->get('password'));
     $user->save();
     Auth::login($user);
     return back()->with('success', 'Zmiany zostały poprawie zapisane');
 }
 public function testAssignUserToNewGroup()
 {
     $this->testCreationNewGroup();
     $user = User::first();
     $group = $this->tester->grabRecord('groups', ['name' => 'Grupa AA']);
     DB::table('group_users')->insert(['user_id' => $user->id, 'group_id' => $group->id]);
     $this->testCreationNewPermission();
     $permission = $this->tester->grabRecord('permissions', ['name' => 'do-smth']);
     $this->tester->seeRecord('group_permissions', ['group_id' => $group->id, 'permission_id' => $permission->id, 'value' => false]);
 }
 /**
  * Potwierdzenie adresu e-mail poprzez link aktywacyjny znajdujacy sie w mailu
  *
  * @return \Illuminate\Http\Response
  */
 public function email()
 {
     $actkey = Actkey::where('user_id', request('id'))->where('actkey', request('actkey'))->firstOrFail();
     $user = User::find(request('id'));
     $user->is_confirm = 1;
     if ($actkey->email) {
         $user->email = $actkey->email;
     }
     $user->save();
     $actkey->delete();
     return redirect(route('home'))->with('success', 'Adres e-mail został pozytywnie potwierdzony');
 }
 /**
  * Wylogowanie uzytkownika
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function signout()
 {
     $user = User::findOrFail(auth()->user()->id);
     $user->ip = request()->ip();
     $user->browser = request()->browser();
     // metoda browser() nie jest dostepna dla testow funkcjonalnych
     $user->visited_at = Carbon::now();
     $user->visits = auth()->user()->visits + 1;
     $user->save();
     stream(Stream_Logout::class);
     Auth::logout();
     return back();
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     // W starej wersji 4programmers.net hasla byly hashowane przy pomocy sha256 + sol. Jezeli w bazie
     // danych jest stary hash, to zmieniamy hasha i zapisujemy do bazy danych
     $events->listen('auth.attempt', function ($credentials) {
         $user = User::where('name', $credentials['name'])->first();
         if ($user && $user->salt && $user->password === hash('sha256', $user->salt . $credentials['password'])) {
             $user->password = bcrypt($credentials['password']);
             $user->salt = null;
             $user->save();
         }
     });
 }
 /**
  * @param UserSettingsRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function save(UserSettingsRequest $request)
 {
     $user = auth()->user();
     if ($user->email !== $request->get('email')) {
         $email = $request->get('email');
         // kasujemy poprzednie rekordu zwiazane z tym userem
         Actkey::where('user_id', $user->id)->delete();
         // przed zmiana e-maila trzeba wyslac link potwierdzajacy
         $actkey = Actkey::create(['actkey' => str_random(), 'user_id' => $user->id, 'email' => $email]);
         // taki format linku zachowany jest ze wzgledu na wsteczna kompatybilnosc.
         // z czasem mozemy zmienic ten format aby wskazywal na /User/Confirm/Email/<id>/<actkey>
         $url = route('user.email') . '?id=' . $user->id . '&actkey=' . $actkey->actkey;
         Mail::queue('emails.email', ['url' => $url], function ($message) use($email) {
             $message->to($email);
             $message->subject('Prosimy o potwierdzenie nowego adresu e-mail');
         });
         if ($user->is_confirm) {
             $request['email'] = $user->email;
         }
     }
     User::find($user->id)->fill($request->all())->save();
     return back()->with('success', 'Zmiany zostały poprawie zapisane');
 }
 /**
  * Obsluga formularza rejestracji uzytkownika
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function signup(Request $request)
 {
     $this->validate($request, ['name' => 'required|min:2|max:28|username|unique:users', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:3', 'human' => 'required']);
     DB::beginTransaction();
     try {
         $email = $request->input('email');
         $user = User::create(['name' => $request->input('name'), 'email' => $email, 'password' => bcrypt($request->input('password'))]);
         $actkey = Actkey::create(['actkey' => str_random(), 'user_id' => $user->id]);
         // taki format linku zachowany jest ze wzgledu na wsteczna kompatybilnosc.
         // z czasem mozemy zmienic ten format aby wskazywal na /User/Confirm/Email/<id>/<actkey>
         $url = route('user.email') . '?id=' . $user->id . '&actkey=' . $actkey->actkey;
         Mail::queue('emails.signup', ['url' => $url], function ($message) use($email) {
             $message->to($email);
             $message->subject('Dziękujemy za rejestrację. Potwierdź autentyczność swojego adresu e-mail');
         });
         Auth::login($user, true);
         stream(Stream_Create::class, new Stream_Person());
         DB::commit();
     } catch (\Exception $e) {
         DB::rollBack();
         throw $e;
     }
     return redirect()->intended(route('home'));
 }
示例#9
0
 protected function _before()
 {
     $fake = Factory::create();
     $this->forum = Forum::create(['name' => $fake->name, 'path' => $fake->name, 'description' => 'Lorem ipsum']);
     $this->user = User::create(['name' => $fake->name, 'email' => $fake->email, 'password' => $fake->password]);
 }
 public function _before(FunctionalTester $I)
 {
     $this->user = User::first();
     $I->amLoggedAs($this->user);
 }
示例#11
0
 private function check($ability, User $user, Post $post, Forum $forum)
 {
     return $user->id === $post->user_id || $forum->ability($ability, $user->id) || $user->ability($ability);
 }
示例#12
0
 public function testSettingsDefault()
 {
     $user = User::where('name', 'admin')->first();
     $this->assertEquals('Lorem ipsum', $user->getSetting('non existing setting', 'Lorem ipsum'));
 }
示例#13
0
 protected function _before()
 {
     $this->user = User::where('name', 'admin')->first();
 }
 public function delete(User $user, Microblog $microblog)
 {
     return $user->id === $microblog->user_id || $user->ability('microblog-delete');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \Coyote\User::create(['name' => 'admin', 'email' => '*****@*****.**', 'password' => bcrypt('123')]);
 }
 /**
  * Gets total reputation ranking
  *
  * @param int $limit
  * @return mixed
  */
 public function total($limit = 3)
 {
     return $this->percentage(User::orderBy('reputation', 'DESC')->take($limit)->get());
 }
示例#17
0
 private function check($ability, User $user, Forum $forum)
 {
     return $forum->ability($ability, $user->id) || $user->ability($ability);
 }
示例#18
0
 /**
  * Sprawdza czy uzytkownicy o podanych loginach znajduja sie w bazie danych.
  *
  * @param array $names
  * @return mixed
  */
 private function findByNames(array $names)
 {
     return $this->user->select(['id', 'name'])->whereIn('name', $names)->get()->lists('name', 'id');
 }