Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use Illuminate\Support\Facades\Auth;
  6. use Invisnik\LaravelSteamAuth\SteamAuth;
  7. use App\Player;
  8.  
  9.  
  10. class AuthController extends Controller
  11. {
  12. /**
  13. * @var SteamAuth
  14. */
  15. private $steam;
  16.  
  17. public function __construct(SteamAuth $steam)
  18. {
  19. $this->steam = $steam;
  20. }
  21.  
  22. public function login()
  23. {
  24. if ($this->steam->validate()) {
  25. $info = $this->steam->getUserInfo();
  26. if (!is_null($info)) {
  27. $user = Player::where('playerid', $info->steamID64)->first();
  28. if (is_null($user)) {
  29. return response()->view('noacc');
  30. }
  31. Auth::login($user, true);
  32. return redirect('/home');
  33. }
  34. }
  35. return $this->steam->redirect();
  36. }
  37.  
  38. public function logout(){
  39. Auth::logout();
  40. return redirect()->route('welcome');
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement