Exemplo n.º 1
0
 public function findByUserNameOrCreate($userData)
 {
     $user = User::where('provider_id', '=', $userData->id)->first();
     if (!$user) {
         $user = User::create(['provider_id' => $userData->id, 'name' => $userData->name, 'username' => $userData->nickname, 'email' => $userData->email, 'avatar' => $userData->avatar, 'active' => 1]);
     }
     $this->checkIfUserNeedsUpdating($userData, $user);
     return $user;
 }
Exemplo n.º 2
0
 /**
  * Obtain the user information from GitHub.
  *
  * @return Response
  */
 public function handleProviderCallback()
 {
     $provider = Input::get('provider');
     $socialite = Socialite::driver($provider)->user();
     $userData = User::where('provider_id', $socialite->id)->first();
     if (!$userData) {
         $userData = User::firstOrCreate(['provider_id' => $socialite->id, 'provider' => $provider, 'name' => $socialite->name, 'username' => $socialite->nickname, 'password' => $socialite->id, 'email' => $socialite->email, 'avatar' => $socialite->avatar]);
     }
     Auth::login($userData, true);
     return redirect()->intended('profile');
 }
Exemplo n.º 3
0
 public function change($id = null)
 {
     // Get user model
     $user = User::find($id);
     //dd(Request::input('access_permission'));
     // Check if requested contain 'access_permission'
     if (Request::has('access_permission')) {
         // Get request input and convert to json
         $request = json_encode(Request::input('access_permission'));
         // Replace the string "true" into true
         $user->permissions = str_replace(':"true"', ':true', $request);
     } else {
         $user->permissions = '';
     }
     // Save user data
     $user->save();
     return response()->json(['status' => '200', 'message' => 'Update Successfull!']);
 }
Exemplo n.º 4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $User = User::findOrFail($id);
     $User->delete();
     Session::flash('flash_message', 'User successfully deleted!');
     return redirect()->route('Users.index');
 }