本文整理汇总了PHP中Sentry::findUserById方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::findUserById方法的具体用法?PHP Sentry::findUserById怎么用?PHP Sentry::findUserById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::findUserById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getList
public function getList()
{
$albums = Album::with('Photos')->with('User')->get();
echo var_export(\Sentry::findUserById(\Sentry::getUser()->id));
exit;
return View::make('index')->with('albums', $albums);
}
示例2: change
public function change()
{
if (Request::isMethod('post')) {
try {
$rules = Validator::make(Input::all(), ['password' => 'required|confirmed', 'password_confirmation' => 'required']);
if ($rules->fails()) {
throw new Exception('Todos los campos son obligatorios');
}
$data = explode('@', Input::get('data'));
$id = base64_decode($data[1]);
$user = Sentry::findUserById($id);
$admin = Sentry::findGroupByName('Administrador');
if (!$user->checkResetPasswordCode($data[0])) {
throw new Exception('El código de chequeo no es correcto.');
}
if (!$user->attemptResetPassword($data[0], Input::get('password_confirmation'))) {
throw new Exception('Se presento un error al guardar la nueva contraseña.');
}
if (!$user->inGroup($admin) || !$user->isActivated()) {
throw new Exception('Este usuario no tiene permisos para ingresar o esta inactivo.');
}
Sentry::login($user);
return Redirect::route('admin.dashboard');
} catch (Exception $e) {
$uri = URL::route('admin.forgot-reset', [Input::get('data')]);
return Redirect::to($uri)->with('message', $e->getMessage());
}
}
}
示例3: loginByToken
public function loginByToken($token = '')
{
if ($token) {
$token = base64_decode($token);
if (User::where('emf_token', '=', $token)->count()) {
$user = User::where('emf_token', '=', $token)->first();
if (is_null($user->last_login)) {
$start_page = 'walkthrough';
$maildata = new stdClass();
$maildata->user = $user->toArray();
Mail::later(8, 'emails.emf.welcome', (array) $maildata, function ($message) use($user) {
$message->to($user->email, $user->first_name && $user->last_name ? $user->first_name . ' ' . $user->last_name : null)->subject('Welcome!');
});
} else {
$start_page = 'dashboard';
}
$sentry_user = Sentry::findUserById($user->id);
Sentry::login($sentry_user, false);
$user->password = md5(uniqid(mt_rand(), true));
$user->emf_token = null;
$user->updated_at = time();
if ($user->save()) {
Log::info('loginByToken() User information was updated.');
} else {
Log::info('loginByToken() User information was not updated!');
}
return Redirect::route($start_page, array('lang' => App::getLocale()));
} else {
return Redirect::route('login', array('lang' => App::getLocale()));
}
} else {
return Redirect::route('login', array('lang' => App::getLocale()));
}
}
示例4: postRegistro
public function postRegistro()
{
$input = Input::all();
$reglas = array('nombre' => 'required', 'apellido' => 'required', 'celular' => 'required|numeric|unique:users', 'cedula' => 'required|numeric|unique:users', 'email' => 'required|email|unique:users', 'pin' => 'required|numeric|digits_between:0,4', 'password' => 'required|numbers|case_diff|letters|min:6|confirmed', 'password_confirmation' => 'required|min:6');
$validation = Validator::make($input, $reglas);
if ($validation->fails()) {
return Response::json(['success' => false, 'errors' => $validation->errors()->toArray()]);
}
try {
// se guarda los datos del usuario
$user = Sentry::register(array('first_name' => Input::get('nombre'), 'last_name' => Input::get('apellido'), 'email' => Input::get('email'), 'habilitar_pin' => 1, 'celular' => Input::get('celular'), 'cedula' => Input::get('cedula'), 'password' => Input::get('password'), 'pin' => Input::get('pin'), 'porcentaje' => 0.05, 'activated' => true));
$userId = $user->getId();
$token = new Token();
$token->user_id = $userId;
$token->api_token = hash('sha256', Str::random(10), false);
$token->client = BrowserDetect::toString();
$token->expires_on = Carbon::now()->addMonth()->toDateTimeString();
$token->save();
// Se autentica de una
$user_login = Sentry::findUserById($userId);
Sentry::login($user_login, false);
return Response::json(['success' => true, 'user' => $user_login, 'token' => $token->api_token]);
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
$error = array('usuario' => 'Email es requerido');
} catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
$error = array('usuario' => 'Password es requerido');
} catch (Cartalyst\Sentry\Users\UserExistsException $e) {
$error = array('usuario' => 'El Email ya está registrado');
}
return Response::json(['success' => false, 'errors' => $error]);
}
示例5: update_post
public function update_post($id)
{
$this->_exists($id);
$rules = User::get_rules($id);
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
// Find the user using the user id
$user = Sentry::findUserById($id);
$user->first_name = Input::get('first_name');
$user->last_name = Input::get('last_name');
$user->tin_number = Input::get('tin_number');
$user->landline = Input::get('landline');
$user->mobile = Input::get('mobile');
$user->work_address = json_endcode(explode(",", Input::get('work_address')));
$user->home_address = json_endcode(explode(",", Input::get('home_address')));
$user->company = Input::get('company');
$user->occupation = Input::get('occupation');
$user->email = Input::get('email');
if (Input::get('password')) {
$user->password = Input::get('password');
}
if (Input::get('activated') == 1) {
$user->activated = true;
} else {
$user->activated = false;
}
$user->save();
return Redirect::to('admin/clients')->with('success', 'Client account has been successfully updated.');
}
return Redirect::to('admin/clients/update/' . $id)->withErrors($validator)->withInput();
}
示例6: pushMessage
public function pushMessage()
{
if (!Sentry::check()) {
return Response::json(array('errCode' => 10, 'message' => '请登录'));
}
Sentry::login(Sentry::findUserById(5), false);
$user = Sentry::getUser();
// $user = User::find(1);
$push_status = PushStatus::where('user_id', $user->id)->first();
if (count($push_status) == 0) {
$push_status = new PushStatus();
$push_status->user_id = $user->id;
$push_status->status = 1;
if (!$push_status->save()) {
return Response::json(array('errCode' => 1, 'message' => '[数据库错误]开启消息推送失败'));
}
return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
}
if ($push_status->status == 1) {
$push_status->status = 0;
if (!$push_status->save()) {
return Response::json(array('errCode' => 2, 'message' => '[数据库错误]开启消息推送失败'));
}
return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
}
if ($push_status->status == 0) {
$push_status->status = 1;
if (!$push_status->save()) {
return Response::json(array('errCode' => 3, 'message' => '[数据库错误]开启消息推送失败'));
}
return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
}
}
示例7: resetPassword
public function resetPassword()
{
$input = Input::all();
$user = User::where('email', '=', $input['email'])->first();
$user = Sentry::findUserById($user->id);
try {
if ($user->checkResetPasswordCode($input['code'])) {
if ($user->attemptResetPassword($input['code'], $input['password'])) {
$data = Citrus::response('data', 1);
$email = new UtilityMailman();
$email->setReceiver($user->email);
$email->setSubject('Successful Password Reset');
$body = $email->getBody('sreset', $user);
$email->setBody($body);
$data = $email->send($user);
} else {
throw new Exception("Something is not right - please request another reset password link.");
}
} else {
throw new Exception("Your reset code has expired. Please request another one.");
}
} catch (Exception $e) {
$data = Citrus::response('error', $e);
}
return $data;
}
示例8: getGraphData
public function getGraphData()
{
if (Sentry::getUser()) {
$user_id = Sentry::getUser()->id;
$period = Input::get('check_report_period');
$mongo_id = Input::get('report_mongo_id');
$check_id = Input::get('report_check_id');
$mongoAPI = new MongoAPI();
$checkAlertEmail = new CheckAlertEmail();
$data = json_decode($mongoAPI->getServerModelData($mongo_id, $period), true);
$data['alert'] = $checkAlertEmail->getDataByCheckId($check_id);
return Response::json($data);
} else {
try {
$user = Sentry::findUserById(Input::get('user_id'));
$emf_group = Sentry::findGroupByName('EmfUsers');
if ($user->inGroup($emf_group)) {
return $this->get_exired_message(Config::get('kuu.emf_login_page'));
} else {
return $this->get_exired_message(URL::route('login'));
}
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
return $this->get_exired_message(URL::route('login'));
} catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
return $this->get_exired_message(URL::route('login'));
}
}
}
示例9: roles
public static function roles($id_group, $id_user)
{
$user = Sentry::findUserById($id_user);
foreach ($user->groups as $group) {
if ($group->id == $id_group) {
return true;
}
}
}
示例10: getUser
public function getUser($id)
{
try {
$user = Sentry::findUserById($id);
return Response::json(array('user' => $user->toArray()));
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
echo 'User was not found.';
}
}
示例11: destroy
public function destroy($id)
{
try {
// Find the user using the user id
$user = Sentry::findUserById($id);
// Delete the user
$user->delete();
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
echo 'User was not found.';
}
}
示例12: postUlogin
public function postUlogin()
{
$_user = json_decode(file_get_contents('http://ulogin.ru/token.php?token=' . Input::get('token') . '&host=' . $_SERVER['HTTP_HOST']), true);
//$user['network'] - соц. сеть, через которую авторизовался пользователь
//$user['identity'] - уникальная строка определяющая конкретного пользователя соц. сети
//$user['first_name'] - имя пользователя
//$user['last_name'] - фамилия пользователя
$validate = Validator::make([], []);
if (isset($_user['error'])) {
$validate->errors()->add('error', trans('larulogin::larulogin.' . $_user['error']));
return Response::make(View::make(Config::get('larulogin::views.error'), ['errors' => $validate->errors()]), 401);
}
// Check exist user
$check = Ulogin::where('identity', '=', $_user['identity'])->first();
if ($check) {
Auth::loginUsingId($check->user_id, true);
if (class_exists('Sentry')) {
$authSentry = Sentry::findUserById($check->user_id);
Sentry::login($authSentry, true);
}
return Redirect::to('/');
}
$rules = array('network' => 'required|max:255', 'identity' => 'required|max:255|unique:ulogin', 'email' => 'required|unique:ulogin|unique:users');
$messages = array('email.unique' => trans('larulogin::larulogin.email_already_registered'));
$validate = Validator::make($_user, $rules, $messages);
if ($validate->passes()) {
$password = str_random(8);
$user = Sentry::createUser(array('first_name' => $_user['first_name'], 'last_name' => $_user['last_name'], 'email' => $_user['email'], 'password' => $password, 'activated' => TRUE));
foreach (Config::get('larulogin::add_to_groups') as $group_name) {
$user->addGroup(Sentry::findGroupByName($group_name));
}
$ulogin = new Ulogin();
$ulogin->user_id = $user->id;
$ulogin->network = $_user['network'];
$ulogin->identity = $_user['identity'];
$ulogin->email = $_user['email'];
$ulogin->first_name = $_user['first_name'];
$ulogin->last_name = $_user['last_name'];
$ulogin->photo = $_user['photo'];
$ulogin->photo_big = $_user['photo_big'];
$ulogin->profile = $_user['profile'];
$ulogin->access_token = isset($_user['access_token']) ? $_user['access_token'] : '';
$ulogin->country = isset($_user['country']) ? $_user['country'] : '';
$ulogin->city = isset($_user['city']) ? $_user['city'] : '';
$ulogin->save();
$authClassic = Auth::loginUsingId($user->id);
if (class_exists('Sentry')) {
$authSentry = Sentry::authenticate(array('email' => $_user['email'], 'password' => $password), true);
}
return Redirect::to('/');
} else {
return Response::make(View::make(Config::get('larulogin::views.error'), array('errors' => $validate->errors())), 401);
}
}
示例13: activate
public function activate($activation_code, $id)
{
try {
$user = \Sentry::findUserById($id);
$user->attemptActivation($activation_code);
} catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
$this->errors[] = trans('auth.user_not_found');
} catch (\Cartalyst\Sentry\Users\UserAlreadyActivatedException $e) {
$this->errors[] = trans('auth.user_already_activated');
}
}
示例14: postPassClinic
/**
* Display a listing of the resource.
*
* @return Response
*/
public function postPassClinic()
{
$id = Input::get('pk');
$pass = Input::get('value');
$user = Sentry::findUserById($id);
$user->password = $pass;
if ($user->save()) {
return 'ok';
} else {
return 'no';
}
}
示例15: editor
/**
* Get the media_entry's editor
* @return string
*/
public function editor()
{
if ($this->updated_by == null) {
return '';
}
try {
$user = Sentry::findUserById($this->updated_by);
return $user->username;
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
return '';
}
}