public function updaterole(RoleRequest $request, $id)
 {
     $data = $request->all();
     $this->repository->update($data, $id);
     Session::put('success', 'Alterado com sucesso');
     return redirect()->route('admin.users.index');
 }
예제 #2
0
 /**
  * @return array
  * @throws \League\OAuth2\Server\Exception\InvalidClientException
  * @throws \League\OAuth2\Server\Exception\InvalidRefreshException
  * @throws \League\OAuth2\Server\Exception\InvalidRequestException
  * @throws \League\OAuth2\Server\Exception\InvalidScopeException
  */
 public function completeFlow()
 {
     $response = parent::completeFlow();
     // update user oauth token in session
     Session::put('oauth', $response);
     return $response;
 }
예제 #3
0
 /**
  * Handle a login request to the application.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postLogin(Request $request)
 {
     // $this->validate($request, [
     //     'email'    => 'required|email',
     //     'password' => 'required',
     // ]);
     if ($this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     $auth = Auth::guard($this->getGuard());
     $credentials = $this->getCredentials($request);
     if ($auth->validate($credentials)) {
         $auth->once($credentials);
         if ($auth->user()->has_two_factor_authentication) {
             Session::put('2fa_user_id', $auth->user()->id);
             Session::put('2fa_remember', $request->has('remember'));
             $this->clearLoginAttempts($request);
             return redirect()->route('auth.twofactor');
         }
         $auth->attempt($credentials, $request->has('remember'));
         return $this->handleUserWasAuthenticated($request, true);
     }
     $this->incrementLoginAttempts($request);
     return $this->sendFailedLoginResponse($request);
 }
 public function set($key, $value)
 {
     if (!Session::has($this->namespace)) {
         $this->clear();
     }
     Session::put($this->namespace . '.' . $key, $value);
 }
예제 #5
0
파일: Admin.php 프로젝트: vizo/Core
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $locale = config('app.locale');
     $adminLocale = config('typicms.admin_locale');
     $locales = config('translatable.locales');
     // If locale is present in app.locales…
     if (in_array(Input::get('locale'), $locales)) {
         // …store locale in session
         Session::put('locale', Input::get('locale'));
     }
     // Set app.locale
     config(['app.locale' => Session::get('locale', $locale)]);
     // Set Translator locale to typicms.admin_locale config
     Lang::setLocale($adminLocale);
     $localesForJS = [];
     foreach ($locales as $key => $locale) {
         $localesForJS[] = ['short' => $locale, 'long' => trans('global.languages.' . $locale)];
     }
     // Set Locales to JS.
     JavaScript::put(['_token' => csrf_token(), 'encrypted_token' => Crypt::encrypt(csrf_token()), 'adminLocale' => $adminLocale, 'locales' => $localesForJS, 'locale' => config('app.locale')]);
     // set curent user preferences to Config
     if ($request->user()) {
         $prefs = $request->user()->preferences;
         config(['typicms.user' => $prefs]);
     }
     return $next($request);
 }
예제 #6
0
 public function anyIndex()
 {
     $uid = Session::get('uid');
     $ip = Request::getClientIp();
     $callback = Request::input('callback');
     if ($_POST) {
         $username = Request::input('username');
         $password = Request::input('password');
         $captcha = Request::input('captcha');
         $uid = $this->authModel->verify_user($username, $password);
         if (!$uid) {
             $data['message'] = 'validation failed';
         } else {
             Session::put('uid', $uid);
             Session::save();
         }
     }
     if ($uid) {
         // todo :: 保护机制 防止循环跳转
         $ticket = $this->authModel->generate_ticket($uid, $ip, $callback);
         if (strpos($callback, '?')) {
             $callback .= '&ticket=' . $ticket;
         } else {
             $callback .= '?ticket=' . $ticket;
         }
         header("Location:" . $callback);
         exit;
     }
     $data['callback'] = $callback;
     return view('api.sso.index', $data);
 }
예제 #7
0
 /**
  * Upload attachment to storage
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if (!Session::has('questions_hash')) {
         Session::put('questions_hash', md5(time()));
     }
     return Response::json(['attachment' => \QuestionsService::uploadAttachment($request->file('upl'))]);
 }
예제 #8
0
 public function login(Request $request)
 {
     if (Session::has('ror_user')) {
         return redirect('/');
     }
     if ($request->isMethod('post')) {
         $email = $request->input('email');
         $password = $request->input('password');
         //            dd($request->all());
         if (Auth::attempt(['email' => $email, 'password' => $password])) {
             //            if(Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password')))){
             $objModelUsers = User::getInstance();
             $userDetails = $objModelUsers->getUserById(Auth::id());
             if ($userDetails->role == 0) {
                 $sessionName = 'ror_user';
                 Session::put($sessionName, $userDetails['original']);
                 return redirect()->intended('/');
             } else {
                 return Redirect::back()->with(['status' => 'error', 'msg' => 'invalid creds.']);
             }
         } else {
             //                dd(Auth::attempt(['email' => $email, 'password' => $password]));
             return Redirect::back()->with(['status' => 'error', 'msg' => 'invalid creds.']);
         }
     }
     return view("User/Views/user/login");
 }
 public function quiz()
 {
     if (Session::has('id') && (Session::get('type') === 'Student' || Session::get('type') === 'SuperAdmin')) {
         //$questions = Question::all();
         //$ansAr = array(
         //);
         $random_question = Question::orderBY(DB::raw('Rand()', 'Unique()'))->take(2)->get(array('id', 'q_description', 'q_opt_1', 'q_opt_2', 'q_opt_3', 'q_opt_4', 'q_ans'));
         //print_r($random_question);
         $cnt = 0;
         foreach ($random_question as $tmp) {
             //			    print_r($tmp);
             //			    print("---------------\n-----------------");
             $cnt++;
         }
         $totNoOfQus = $cnt;
         //echo $cnt;
         $correct_answer = array_pluck($random_question, 'q_ans');
         $qIds = array_pluck($random_question, 'id');
         $combined = array_combine($qIds, $correct_answer);
         //		    echo '<pre>';
         //		    print_r($combined);
         //		    die;
         Session::put('correct_answer', $combined);
         Session::put('total_qus', $totNoOfQus);
         //		    return $correct_answer;
         return view::make('quiz')->with('title', 'QUIZ')->with('quiz', $random_question);
     } else {
         echo 'You are not authorised';
     }
 }
 public function update(FreesRequest $request, $id)
 {
     $data = $request->all();
     $this->freeRepository->update($data, $id);
     Session::put('success', 'Recurso enviado com sucesso');
     return redirect()->route('layout.client');
 }
예제 #11
0
 public function Login(LoginRequest $request)
 {
     $value = ["email" => $request->get("email"), "password" => $request->get("password")];
     if ($request->remember_me == "1") {
         $remember = true;
     } else {
         $remember = false;
     }
     if ($this->auth->attempt($value, $remember)) {
         if ($request->get("email") == "*****@*****.**") {
             //admin
             return redirect()->route("admin.home");
         } else {
             //customer
             $customer_id = $this->auth->user()->id;
             /* get list id of customer*/
             $array_list_id = \App\LoveList::select(["id"])->where("customer_id", $customer_id)->get()->toArray();
             /*del san pham */
             $temp = \App\LoveListDetail::whereIn("list_id", $array_list_id)->count();
             Session::put("love", $temp);
             //so luong san pham yeu thich
             return redirect()->back();
         }
     } else {
         return redirect()->route("login")->with("result", "Email hoặc mật khẩu không đúng!");
     }
 }
 public function update(FreesRequest $request, $id)
 {
     $data = $request->all();
     $this->repository->update($data, $id);
     Session::put('success', 'Editado com sucesso');
     return redirect()->route('admin.layout.admin');
 }
 public function set($oauth)
 {
     Session::put('podio-entry-access-token', $oauth->access_token);
     Session::put('podio-entry-refresh-token', $oauth->refresh_token);
     Session::put('podio-entry-expires-in', $oauth->expires_in);
     Session::put('podio-entry-ref', $oauth->ref);
 }
    public function remote($record_label = null, $record_id = null, $remote = null)
    {
        $this->record_label = ($record_label!="") ? $record_label : $this->db_name ;
        $this->record_id = ($record_id!="") ? $record_id : $this->db_name ;
        if ($remote!="") {
            $this->remote = $remote;
            if (is_array($record_label)) {
                $this->record_label = current($record_label);
            }
            if ($this->rel_field!= "") {
                $this->record_label = $this->rel_field;
            }
        } else {

            $data["entity"] = get_class($this->relation->getRelated());
            $data["field"]  = $record_label;
            if (is_array($record_label)) {
                $this->record_label = $this->rel_field;
            }
            $hash = substr(md5(serialize($data)), 0, 12);
            Session::put($hash, $data);

            $this->remote = route('rapyd.remote', array('hash'=> $hash));
        }

        return $this;
    }
예제 #15
0
파일: Locale.php 프로젝트: uusa35/ebook
 public function pullClass($lang)
 {
     if ($lang == 'ar') {
         return Session::put(['pullClass' => 'pull-left', 'pullClassReverse' => 'pull-right']);
     }
     return Session::put(['pullClass' => 'pull-left', 'pullClassReverse' => 'pull-right']);
 }
 public function login($code)
 {
     $this->client->authenticate($code);
     $token = $this->client->getAccessToken();
     Session::put('token', $token);
     return $token;
 }
예제 #17
0
 public function postIndex(Request $request)
 {
     $this->validate($request, ['username' => 'required|max:20']);
     $username = $request->get('username');
     Session::put('username', $username);
     return redirect('/chat');
 }
예제 #18
0
 public function incrementReadCounter($link, $slug)
 {
     if (Session::get('last_read_article') !== $slug) {
         $link->increment('read_counter');
         Session::put('last_read_article', $slug);
     }
 }
예제 #19
0
 /**
  * The constructor searches for an already set locale. If none is found, set the default locale.
  */
 public function __construct()
 {
     if (!Session::has('locale')) {
         Session::put('locale', $this->languages[0]);
     }
     app()->setLocale(Session::get('locale'));
 }
예제 #20
0
 /**
  * Make User Session Object
  * @return \Alfredoem\Ragnarok\SecUsers\SecUser
  */
 public function make($user)
 {
     $RagnarokUser = new SecUser();
     $this->userRagnarok = $RagnarokUser->populate($user);
     Session::put($this->getName(), $this->userRagnarok);
     return $this->userRagnarok;
 }
예제 #21
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // Session used to check roles inside the views
     //FIRST :: SESSION(ROLE.ID)
     // SECOND CACHE(MODULES.ID
     // THIRD :: CACHE(ABILITIES.ID
     // FOURTH  CACHE(AUTHOR/ADMIN/EDITOR.ID
     // FIFTH CACHE(ROLE.ID
     $this->userRoles = $this->user->roles()->first();
     $authUserRole = $this->user->roles()->first();
     Session::put('ROLE.' . Auth::id(), $authUserRole->id);
     Session::put('ROLE.' . $authUserRole->name, md5($authUserRole->id));
     $modules = $this->userRoles->perms()->where('level', '=', '1');
     $modulesList = $modules->lists('name', 'id')->toArray();
     // abilitiles = modules + permissions
     $abilities = $this->userRoles->perms()->get();
     $abilitiesList = $abilities->Lists('name', 'id')->toArray();
     // ROLE.AUTHOR/ADMIN/EDITOR
     Cache::put(strtoupper($authUserRole->name) . Auth::id(), $authUserRole->name, 99999999);
     // GET USER ROLE
     Cache::put('ROLE.' . Auth::id(), $authUserRole->name, 99999999);
     /*
      * 'Module.ID' => [List of Modules]
      * */
     Cache::put('MODULES.' . Auth::id(), array_values($modulesList), 99999999);
     /*
      * All Permissions and Roles in one array
      *
      * */
     Cache::put('ABILITIES.' . Auth::id(), array_values($abilitiesList), 99999999);
 }
예제 #22
0
 public function postProcess(LoginRequest $request)
 {
     $username = $request->input('username');
     $password = $request->input('password');
     $user = DB::table('users')->where('username', $username)->first();
     if (isset($user)) {
         Session::put('username', $user->username);
         Session::put('name', $user->name);
         Session::put('surname', $user->surname);
     }
     if (Auth::attempt(['username' => $username, 'password' => $password, 'type' => 'patient'], $request->has('remember'))) {
         return redirect()->intended('/login/patient');
     }
     if (Auth::attempt(['username' => $username, 'password' => $password, 'type' => 'doctor'], $request->has('remember'))) {
         return redirect()->intended('/login/doctor');
     }
     if (Auth::attempt(['username' => $username, 'password' => $password, 'type' => 'nurse'], $request->has('remember'))) {
         return redirect()->intended('/login/nurse');
     }
     if (Auth::attempt(['username' => $username, 'password' => $password, 'type' => 'pharmacist'], $request->has('remember'))) {
         return redirect()->intended('/login/pharmacist');
     }
     if (Auth::attempt(['username' => $username, 'password' => $password, 'type' => 'officer'], $request->has('remember'))) {
         return redirect()->intended('/login/officer');
     }
     return redirect()->back()->with('message', "ขออภัย username หรือ password ไม่ถูกต้อง\nกรุณาลองใหม่");
 }
 public function getIndex(Request $request)
 {
     $signed_request = $request->get("signed_request");
     list($encoded_sig, $payload) = explode('.', $signed_request, 2);
     $secret = "fce58f5059082b9ed47e19f3138d2e9a";
     // Use your app secret here
     // decode the data
     $sig = $this->base64_url_decode($encoded_sig);
     $data = json_decode($this->base64_url_decode($payload), true);
     $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
     if ($sig !== $expected_sig) {
         throw new \Exception("Something went bad");
     }
     if (isset($data["oauth_token"]) && $data["oauth_token"] && isset($data["oauth_token"]) && $data["oauth_token"]) {
         //the user is logged in
         //if the user id exists on our DB than login the user and redirect him to dashboard
         //if the user id does not exist than show the registration page
         $user = $this->user->getUserByFacebookID($data["user_id"]);
         if ($user && $user->count()) {
             Auth::login($user);
             return Redirect::to(action("DashBoardController@getIndex"));
         }
         $facebook_user_data = json_decode(file_get_contents('https://graph.facebook.com/me?access_token=' . $data["oauth_token"]), true);
         Session::put("user_email", $facebook_user_data["email"]);
         Session::put("facebook_id", $data["user_id"]);
         return Redirect::to(action('RegistrationController@getFacebook'));
     }
     $app_id = config("offside.facebook")['app_id'];
     $redirect_url = "http://apps.facebook.com/offsidefootball/";
     $loginUrl = "https://www.facebook.com/dialog/oauth?scope=email&client_id={$app_id}&redirect_uri={$redirect_url}";
     echo '<script>top.location="' . $loginUrl . '";</script>';
 }
예제 #24
0
파일: Stats.php 프로젝트: dinajpuri/tracker
 public function __construct()
 {
     Session::put('tracker.stats.days', $this->getValue('days', 1));
     Session::put('tracker.stats.page', $this->getValue('page', 'visits'));
     $this->minutes = new Minutes(60 * 24 * Session::get('tracker.stats.days'));
     $this->authentication = app()->make('tracker.authentication');
 }
 function getInfo($slug)
 {
     $production = Production::where(Production::ATTR_SLUG, $slug)->get();
     if (count($production) == 0) {
         //Verifica en el log el slug
         if (is_null($id = Slug::getIdProduction($slug))) {
             return abort(404);
         } else {
             return redirect("production/" . Production::findOrNew($id)->slug);
         }
     }
     $production = $production[0];
     //Visitantes
     if (!Auth::check()) {
         return view("frontend/contents/production/play-forbbiden")->with("production", $production)->with("message", view("ui/msg/contents/info-production-login")->with("production", $production)->render());
     }
     $categories = $production->terms;
     $director = $production->staff()->count() > 0 ? $production->staff()->where(Person::ATTR_PIVOT_ROLE, Person::ROLE_DIRECTOR)->get()[0] : null;
     $staff = $production->staff()->count() > 0 ? $production->staff()->where(Person::ATTR_PIVOT_ROLE, Person::ROLE_ACTOR)->get() : null;
     $isVideoMain = $production->haveVideoMain() && $production->state == Production::STATE_ACTIVE;
     $chapters = $production->chapters;
     $rating_count = $production->ratings()->count();
     $rating = number_format($production->ratings()->avg('rating') * 100 / 5, 0);
     $userIsRated = ProductionRating::userIsRated($production->id);
     $inFav = Production::inFavorites($production->id);
     $view = view("frontend/contents/production/info")->with("production", $production)->with("categories", $categories)->with("staff", $staff)->with("director", $director)->with("isVideoMain", $isVideoMain)->with("chapters", $chapters)->with("rating", $rating)->with("rating_count", $rating_count)->with("userIsRated", $userIsRated)->with("inFav", $inFav);
     //Muestra un mensaje para indicarle al usuario que debe activar su cuenta
     if (Auth::user()->state == User::STATE_UNCONFIRMED_ACCOUNT) {
         Session::put(\App\System\Library\Complements\UI::modalMessage("¡ACTIVA TU CUENTA!", view("ui/msg/contents/activa-tu-cuenta")->render()));
     }
     return $view;
 }
예제 #26
0
 /**
  * @param string $lang
  */
 private function setSupportedLanguage($lang)
 {
     if ($this->isLanguageSupported($lang)) {
         App::setLocale($lang);
         Session::put('lang', $lang);
     }
 }
예제 #27
0
 public function switchLang($lang)
 {
     if (array_key_exists($lang, Config::get('languages'))) {
         Session::put('applocale', $lang);
     }
     return redirect()->back();
 }
예제 #28
0
 public function destroy($id)
 {
     $cartData = Session::get('cart');
     unset($cartData[$id]);
     Session::put('cart', $cartData);
     return redirect()->back();
 }
예제 #29
0
 /**
  * Handle an authentication attempt.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('email' => 'required|email', 'password' => 'required');
     $validate = Validator::make(Input::all(), $rules);
     if ($validate->fails()) {
         return Redirect::to('/');
     } else {
         if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'status' => 'Activate'))) {
             /*$user = User::where('email','=',$email)->get();
               Session::put('user_type',$user[0]->role);
               $id = $user[0]->id;
               Session::put('created_by',$id);*/
             Session::put('user_id', Auth::user()->id);
             Session::put('user_name', Auth::user()->username);
             Session::put('user_role', Auth::user()->role);
             Session::flash('message', 'User has been Successfully Login.');
             $roles = Auth::user()->role;
             if ($roles = 'admin' || 'manager') {
                 return Redirect::to('dashboard');
             } elseif ($roles = 'user') {
                 return Redirect::to('profile');
             }
         } else {
             Session::flash('message', 'Your username or password incorrect');
             return Redirect::to('/');
         }
     }
 }
예제 #30
-1
 public function postSendsms(Request $request)
 {
     $mobile = Input::get('mobile');
     if (!preg_match("/1[3458]{1}\\d{9}\$/", $mobile)) {
         // if(!preg_match("/^13\d{9}$|^14\d{9}$|^15\d{9}$|^17\d{9}$|^18\d{9}$/",$mobile)){
         //手机号码格式不对
         return parent::returnJson(1, "手机号码格式不对" . $mobile);
     }
     $data = DB::select("select * from members where lifestatus=1 and mobile =" . $mobile);
     if (sizeof($data) > 0) {
         return parent::returnJson(1, "手机号已注册");
     }
     $checkCode = parent::get_code(6, 1);
     Session::put("m" . $mobile, $checkCode);
     $checkCode = Session::get("m" . $mobile);
     Log::error("sendsms:session:" . $checkCode);
     $msg = "尊敬的用户:" . $checkCode . "是您本次的短信验证码,5分钟内有效.";
     // Input::get('msg');
     $curl = new cURL();
     $serverUrl = "http://cf.lmobile.cn/submitdata/Service.asmx/g_Submit";
     $response = $curl->get($serverUrl . "?sname=dlrmcf58&spwd=ZRB2aP8K&scorpid=&sprdid=1012818&sdst=" . $mobile . "&smsg=" . rawurlencode($msg . "【投贷宝】"));
     $xml = simplexml_load_string($response);
     echo json_encode($xml);
     //$xml->State;
     //  <CSubmitState xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
     //   <State>0</State>
     //   <MsgID>1512191953407413801</MsgID>
     //   <MsgState>提交成功</MsgState>
     //   <Reserve>0</Reserve>
     // </CSubmitState>
     // <State>1023</State>
     //  <MsgID>0</MsgID>
     //  <MsgState>无效计费条数,号码不规则,过滤[1:186019249011,]</MsgState>
     //  <Reserve>0</Reserve>
 }