Ejemplo n.º 1
0
 public function postAdminAccount()
 {
     $data = Input::all();
     //return View::make('install.done');
     try {
         $user = Sentry::createUser(array('email' => $data['email'], 'password' => $data['password'], 'activated' => true, 'first_name' => $data['first_name'], 'last_name' => $data['last_name']));
         $group = Sentry::findGroupByName('admin');
         $user->addGroup($group);
         $quicknote = new \Quicknote();
         $quicknote->user_id = $user->id;
         $quicknote->save();
         $userProfile = new \UserProfile();
         $userProfile->id = $user->id;
         $userProfile->save();
         $imageResult = App::make('AuthController')->{'createUserImage'}($user->id, $data['first_name'][0], $data['last_name'][0]);
         $installationDate = date('Y-m-d H:i:s');
         $installationHost = Request::server('PATH_INFO');
         $new92fiveConfig = new NewConfig();
         $new92fiveConfig->toFile(app_path() . '/config/92five.php', ['install' => true, 'version' => '1.0', 'installationDate' => $installationDate, 'installationHost' => $installationHost]);
         return View::make('install.done');
     } catch (Exception $e) {
         Log::error('Something Went Wrong in Install Controller Repository - addUserWithDetails():' . $e->getMessage());
         throw new Exception('Something Went Wrong in Install Controller Repository - addUserWithDetails()');
     }
 }
Ejemplo n.º 2
0
 public function addUserWithDetails($data)
 {
     $checkEmail = \User::where('email', $data['email'])->get()->toArray();
     if (sizeof($checkEmail) != 0) {
         throw new \Exception('User with Email Already Exists');
     }
     try {
         $user = \Sentry::createUser(array('email' => $data['email'], 'password' => $data['password'], 'activated' => true, 'first_name' => $data['first_name'], 'last_name' => $data['last_name']));
         $group = \Sentry::findGroupByName($data['role']);
         $user->addGroup($group);
         $quicknote = new \Quicknote();
         $quicknote->user_id = $user->id;
         $quicknote->save();
         $userProfile = new \UserProfile();
         $userProfile->id = $user->id;
         $userProfile->save();
         $imageResult = \App::make('AuthController')->{'createUserImage'}($user->id, $data['first_name'][0], $data['last_name'][0]);
         return true;
     } catch (\Exception $e) {
         \Log::error('Something Went Wrong in User Repository - addUserWithDetails():' . $e->getMessage());
         return false;
     }
 }
Ejemplo n.º 3
0
 /**
  *	Create User
  */
 public function authCreateUser()
 {
     $data = Input::all();
     try {
         // Find the user using the user id
         $user = Sentry::getUserProvider()->findByLogin($data['email']);
         // Attempt to activate the user
         $result = $user->attemptActivation($data['token']);
         //Assign the data
         $user->password = $data['password'];
         $user->first_name = ucfirst($data['first_name']);
         $user->last_name = ucfirst($data['last_name']);
         //Generate the profile pic
         $result = static::createUserImage($user->id, $user->first_name, $user->last_name);
         // Create a row for user in Quick Note Table
         $quicknote = new Quicknote();
         $quicknote->user_id = $user->id;
         $quicknote->save();
         //Create a row for user in User Profile Table
         $userProfile = new UserProfile();
         $userProfile->id = $user->id;
         $userProfile->save();
         //Update the user and save all data
         if ($user->save()) {
             //Redirect the user to the login page with appropriate display message
             return Redirect::to('login')->with('message', 'success103');
         } else {
             Log::error('Something Went Wrong Exception - Creating User for email ' . $data['email']);
             throw new SomeThingWentWrongException();
         }
     } catch (UserNotFoundException $e) {
         throw new UserNotFoundException();
     } catch (UserAlreadyActivatedException $e) {
         Log::error('Something Went Wrong Exception - User is already activated for email ' . $data['email']);
         throw new SomeThingWentWrongException();
     }
 }