Ejemplo n.º 1
0
 public function loginuser(Request $request)
 {
     $rules = ['email' => 'required|string', 'password' => 'required'];
     $nicename = ['email' => 'username', 'password' => 'password'];
     $validator = \Illuminate\Support\Facades\Validator::make($request->all(), $rules);
     $validator->setAttributeNames($nicename);
     if ($validator->fails()) {
         $request->flash();
         return redirect()->back()->withErrors($validator);
     }
     if ($request->has('password') && $request->has('email')) {
         if (\Auth::organization()->attempt(['email' => $request->input('email'), 'password' => $request->input('password')])) {
             $org = \DB::table('organization_details')->where('organization_details.organization', '=', \Auth::organization()->get()->id)->get(['id']);
             if ($org != null) {
                 return "here";
                 //                    return redirect()->intended('home');
             } else {
                 return redirect()->intended('organizations/first-signin/' . \Auth::organization()->get()->id);
             }
             //                 Authentication passed...
         } else {
             $request->flash();
             return redirect()->back()->withErrors(['loginwrong' => 'check your access info']);
         }
     }
 }