<commit_before><?php namespace Zeropingheroes\LanagerCore;

use Zeropingheroes\LanagerCore\Models\User,
	Zeropingheroes\LanagerCore\Models\SteamState,
	Zeropingheroes\LanagerCore\Repositories\SteamUserRepositoryInterface;
use \LightOpenID;
use App, Auth, Input, Request, Redirect, View;

class UserController extends BaseController {

	protected $steamUsers;
	
	public function __construct(SteamUserRepositoryInterface $steamUsers)
	{
		$this->steamUsers = $steamUsers;
	}


	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		$users = User::orderBy('username', 'asc')->paginate(10);
		return View::make('lanager-core::user.list')
					->with('title','People')
					->with('users',$users);
	}

	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		//
	}

	/**
	 * Store a newly created resource in storage.
	 *
	 * @param  object  SteamUser $steamUser
	 * @return Response
	 */
	public function store($steamUser)
	{
		//
	}

	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
		if( $user = User::find($id) )
		{
			return View::make('lanager-core::user.show')
						->with('title',$user->username)
						->with('user',$user);
		}
		else
		{
			App::abort(404, 'Page not found');
		}
	}

	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		//
	}

	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		//
	}

	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		//
	}

	/**
	 * Authenticate the user using OpenID
	 *
	 * @return Redirect
	 */
	public function openIdLogin()
	{
		if(Input::has('openid_mode'))
		{
			$openId = new LightOpenID(Request::server('HTTP_HOST'));
	
			if($openId->validate())
			{
				$steamId = str_replace('http://steamcommunity.com/openid/id/','',$openId->identity);
				
				if($this->importSteamUser($steamId))
				{
					$user = User::where('steam_id_64', '=', $steamId)->first();
					Auth::login($user);
					return Redirect::to('/');
				}
				else
				{
					App::abort(500, 'Could not import user from Steam into database.');
				}
			}
			else
			{
				App::abort(500, 'Could not validate OpenID.');
			}
		}
		else
		{<commit_msg>Make the first user to log in a SuperAdmin<commit_after><?php namespace Zeropingheroes\LanagerCore;

use Zeropingheroes\LanagerCore\Models\User,
	Zeropingheroes\LanagerCore\Models\SteamState,
	Zeropingheroes\LanagerCore\Models\Role,
	Zeropingheroes\LanagerCore\Repositories\SteamUserRepositoryInterface;
use \LightOpenID;
use App, Auth, Input, Request, Redirect, View;

class UserController extends BaseController {

	protected $steamUsers;
	
	public function __construct(SteamUserRepositoryInterface $steamUsers)
	{
		$this->steamUsers = $steamUsers;
	}


	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
		$users = User::orderBy('username', 'asc')->paginate(10);
		return View::make('lanager-core::user.list')
					->with('title','People')
					->with('users',$users);
	}

	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		//
	}

	/**
	 * Store a newly created resource in storage.
	 *
	 * @param  object  SteamUser $steamUser
	 * @return Response
	 */
	public function store($steamUser)
	{
		//
	}

	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
		if( $user = User::find($id) )
		{
			return View::make('lanager-core::user.show')
						->with('title',$user->username)
						->with('user',$user);
		}
		else
		{
			App::abort(404, 'Page not found');
		}
	}

	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		//
	}

	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		//
	}

	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		//
	}

	/**
	 * Authenticate the user using OpenID
	 *
	 * @return Redirect
	 */
	public function openIdLogin()
	{
		if(Input::has('openid_mode'))
		{
			$openId = new LightOpenID(Request::server('HTTP_HOST'));
	
			if($openId->validate())
			{
				$steamId = str_replace('http://steamcommunity.com/openid/id/','',$openId->identity);
				
				if($this->importSteamUser($steamId))
				{
					$user = User::where('steam_id_64', '=', $steamId)->first();
					Auth::login($user);

					// Make the first user SuperAdmin
					if( count(User::all()) == 1 )	$user->roles()->attach(Role::where('name', '=', 'SuperAdmin')->firstOrFail());

					return Redirect::to('/');
				}
				else
				{
					App::abort(500, 'Could not import user from Steam into database.');
				}
			}
			else
			{
				App::abort(500, 'Could not validate OpenID.');
			}
		}
		else
		{
{'fraction_non_alphanumeric': 0.1578545523954953, 'fraction_numerical': 0.005153655277724756, 'mean_word_length': 3.058869093725794, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5089393', 'n_tokens_mistral': 2090, 'n_tokens_neox': 1776, 'n_words': 387}