Example #1
0
 protected function createTestUser()
 {
     $this->user = new User();
     $this->user->attributes = array('active' => 1, 'global_firm_rights' => 1, 'first_name' => 'Auto-Test', 'last_name' => 'API', 'password' => $this->user_password, 'password_repeat' => $this->user_password, 'username' => 'autotestapi', 'email' => '*****@*****.**');
     $this->user->id = 99999;
     $this->user->noVersion()->save();
     $this->user->saveRoles(array('User', 'API access'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $this->user->username = Input::get('username');
     $this->user->email = Input::get('email');
     $this->user->password = Input::get('password');
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $this->user->password_confirmation = Input::get('password_confirmation');
     $this->user->confirmed = Input::get('confirm');
     // Permissions are currently tied to roles. Can't do this yet.
     //$user->permissions = $user->roles()->preparePermissionsForSave(Input::get( 'permissions' ));
     // Save if valid. Password field will be hashed before save
     $this->user->save();
     if ($this->user->id) {
         // Save roles. Handles updating.
         $this->user->saveRoles(Input::get('roles'));
         // Redirect to the new user page
         return Redirect::to('admin/users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
Example #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $this->user->username = Input::get('username');
     $this->user->email = Input::get('email');
     $this->user->password = Input::get('password');
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $this->user->password_confirmation = Input::get('password_confirmation');
     $this->user->confirmed = Input::get('confirm');
     // Permissions are currently tied to roles. Can't do this yet.
     //$user->permissions = $user->roles()->preparePermissionsForSave(Input::get( 'permissions' ));
     // Save if valid. Password field will be hashed before save
     $this->user->engine_key = Hash::make(uniqid(mt_rand(), true));
     $this->user->save();
     try {
         // Register the user on the engine
         $return = xDockerEngine::register(array('username' => $this->user->username, 'password' => $this->user->engine_key));
         Log::info("Return Status : " . $return);
         EngineLog::logIt(array('user_id' => $this->user->id, 'method' => 'admin:register', 'return' => $return));
     } catch (Exception $e) {
         Log::error('Error while registering the user!' . $e->getMessage());
     }
     if ($this->user->id) {
         // Save roles. Handles updating.
         $this->user->saveRoles(Input::get('roles'));
         // Redirect to the new user page
         return Redirect::to('admin/users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $rules = array('displayname' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed|min:4');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $this->user->displayname = Input::get('displayname');
         $this->user->email = Input::get('email');
         $this->user->password = Input::get('password');
         $this->user->password_confirmation = Input::get('password_confirmation');
         $this->user->confirmed = Input::get('confirm');
         $this->user->save();
         Event::fire('controller.user.create', array($this->user));
         if ($this->user->id) {
             $this->user->saveRoles(Input::get('roles'));
             $pro = Input::get('user_profiles');
             $profile = new UserProfile($pro['new']);
             $user = User::find($this->user->id);
             $user->profiles()->save($profile);
             Activity::log(array('contentID' => $this->user->id, 'contentType' => 'account_created', 'description' => $this->user->id, 'details' => 'account_created', 'updated' => Confide::user()->id ? true : false));
             return Api::to(array('success', Lang::get('admin/users/messages.create.success'))) ?: Redirect::to('admin/users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
         } else {
             return Api::to(array('error', $this->user->errors()->all())) ?: Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', $this->user->errors()->all());
         }
     } else {
         return Api::to(array('error', Lang::get('admin/users/messages.edit.error'))) ?: Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', Lang::get('admin/users/messages.edit.error'))->withErrors($validator);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate()
 {
     $this->user->displayname = Input::get('displayname');
     $this->user->email = Input::get('email');
     $this->user->password = Input::get('password');
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $this->user->password_confirmation = Input::get('password_confirmation');
     $this->user->confirmed = Input::get('confirm');
     // Save if valid. Password field will be hashed before save
     $this->user->save();
     if ($this->user->id) {
         // Save roles. Handles updating.
         $this->user->saveRoles(Input::get('roles'));
         $pro = Input::get('user_profiles');
         $profile = new UserProfile($pro['new']);
         $user = User::find($this->user->id);
         $user->profiles()->save($profile);
         // Redirect to the new user page
         return Redirect::to('admin/users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
 /**
  * Stores new account
  *
  */
 public function store()
 {
     // Validate the inputs
     $rules = array('username' => 'required|alpha_dash|unique:users,username', 'fullname' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'between:4,11|confirmed', 'password_confirmation' => 'between:4,11');
     $this->user->username = Input::get('username');
     $this->user->fullname = Input::get('fullname');
     $this->user->email = Input::get('email');
     $this->user->password = Input::get('password');
     // The password confirmation will be removed from model
     // before saving. This field will be used in Ardent's
     // auto validation.
     $this->user->password_confirmation = Input::get('password_confirmation');
     $this->user->confirmed = Input::get('confirm');
     // Permissions are currently tied to roles. Can't do this yet.
     //$user->permissions = $user->roles()->preparePermissionsForSave(Input::get( 'permissions' ));
     // Save if valid. Password field will be hashed before save
     $this->user->save($rules);
     if ($this->user->id) {
         // Save roles. Handles updating.
         $this->user->saveRoles(Input::get('roles'));
         // Redirect to the new user page
         //return Redirect::to('users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
         return Redirect::to('admin/users')->with('success', Lang::get('admin/user/messages.create.success'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('admin/users/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
Example #7
0
 /**
  * Stores new account
  *
  */
 public function store()
 {
     $this->user->username = Input::get('username');
     $this->user->email = Input::get('email');
     $this->user->nombre = Input::get('nombre');
     $this->user->apepat = Input::get('apepat');
     $this->user->apemat = Input::get('apemat');
     $this->user->password = Input::get('password');
     $this->user->password_confirmation = Input::get('password_confirmation');
     $this->user->confirmed = true;
     if ($this->user->save()) {
         // Save if valid. Password field will be hashed before save
         // Save roles. Handles updating.
         $this->user->saveRoles(Input::get('roles'));
         return Redirect::to('admin/user/create')->with('success', "Se ha crado correctamente el usuario " . $this->user->nombreCompleto());
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors;
         return Redirect::to('admin/user/create')->withInput()->withErrors($error);
     }
 }
 public function actionAddUser()
 {
     $user = new User();
     $request = Yii::app()->getRequest();
     if ($request->getIsPostRequest()) {
         $userAtt = $request->getPost('User');
         $user->attributes = $userAtt;
         if (!$user->validate()) {
             $errors = $user->getErrors();
         } else {
             if (!$user->save()) {
                 throw new Exception("Unable to save user: " . print_r($user->getErrors(), true));
             }
             Audit::add('admin-User', 'add', $user->id);
             if (!isset($userAtt['roles'])) {
                 $userAtt['roles'] = array();
             }
             $user->saveRoles($userAtt['roles']);
             $this->redirect('/admin/users/' . ceil($user->id / $this->items_per_page));
         }
     }
     $user->password = '';
     $this->render('/admin/adduser', array('user' => $user, 'errors' => @$errors));
 }
Example #9
0
 /**
  * Update the specified resource in storage.
  *
  * @param User $user
  * @return Response
  */
 public function postEdit($user)
 {
     $oldUser = clone $user;
     $user->username = Input::get('username');
     $user->email = Input::get('email');
     $user->confirmed = Input::get('confirm');
     $user->full_name = Input::get('full_name');
     $password = Input::get('password');
     $passwordConfirmation = Input::get('password_confirmation');
     if (!empty($password)) {
         if ($password === $passwordConfirmation) {
             $user->password = $password;
             // The password confirmation will be removed from model
             // before saving. This field will be used in Ardent's
             // auto validation.
             $user->password_confirmation = $passwordConfirmation;
         } else {
             // Redirect to the new user page
             return Redirect::to('admin/users/' . $user->id . '/edit')->with('error', Lang::get('admin/users/messages.password_does_not_match'));
         }
     }
     if ($user->confirmed == null) {
         $user->confirmed = $oldUser->confirmed;
     }
     if ($user->save()) {
         // Save roles. Handles updating.
         $user->saveRoles(Input::get('roles'));
     } else {
         $errors = $user->errors();
         return Redirect::to('admin/users/' . $user->id . '/edit')->with('error', Lang::get('admin/users/messages.edit.error'))->with('errors', $errors);
     }
     // Get validation errors (see Ardent package)
     //$errors = $user->errors()->all();
     $errors = $user->errors();
     if ($errors->count() == 0) {
         // Redirect to the new user page
         return Redirect::to('admin/users/' . $user->id . '/edit')->with('success', Lang::get('admin/users/messages.edit.success'));
     } else {
         return Redirect::to('admin/users/' . $user->id . '/edit')->with('error', Lang::get('admin/users/messages.edit.error'))->with('errors', $errors);
     }
 }