function __construct()
 {
     $count = getInput("count");
     $email = getInput("email");
     $password = getInput("password");
     $x = 0;
     while ($x < $count) {
         $first_name = $this->names[mt_rand(0, sizeof($this->names) - 1)];
         $last_name = $this->surnames[mt_rand(0, sizeof($this->surnames) - 1)];
         $user = new User();
         $user->password = md5($password);
         $user->random = true;
         $user->verified = "true";
         $user->profile_type = "default";
         $user->access_id = "system";
         $user->first_name = $first_name;
         $user->last_name = $last_name;
         $user->email = "tester" . $x . "@" . $email;
         $user->full_name = $first_name . " " . $last_name;
         $user->save();
         $x++;
     }
     new SystemMessage("Random users have been generated");
     forward();
 }
 public function createParent()
 {
     $input = Input::all();
     if (Input::hasFile('profilepic')) {
         $input['profilepic'] = $this->filestore(Input::file('profilepic'));
     }
     $input['dob'] = date('Y-m-d H:i:s', strtotime(Input::get('dob')));
     $input['collegeid'] = Session::get('user')->collegeid;
     $input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
     //$input['collegeid']="dummy";
     //$input['collegename']="dummy";
     $user = new User();
     $user->email = $input['email'];
     $user->password = Hash::make($input['password']);
     $user->collegeid = $input['collegeid'];
     $user->flag = 3;
     $user->save();
     $input['loginid'] = $user->id;
     $removed = array('_token', 'password', 'cpassword');
     foreach ($removed as $k) {
         unset($input[$k]);
     }
     Parent::saveFormData($input);
     return $input;
 }
Example #3
0
 public static function login($result, $token, $token_exp)
 {
     if ($result->id) {
         $user = User::checkUserExists($result->id);
         if (!$user) {
             $user = new User();
             $user->name = $result->firstName . " " . $result->lastName;
             $user->linkedin_id = $result->id;
             $user->pic_url = $result->pictureUrl;
             $user->profile_url = $result->publicProfileUrl;
             $user->api_url = $result->apiStandardProfileRequest->url;
             $user->linkedin_token = $token;
             $user->linkedin_token_exp = date("Y-m-d H:i:s", $token_exp);
             $user->company_id = Company::getPublicUserCompanyId();
             $user->save(TRUE);
         } else {
             $user->linkedin_token = $token;
             $user->linkedin_token_exp = date("Y-m-d H:i:s", $token_exp);
             $user->save(FALSE);
         }
         HttpSession::setUser($user);
         //if user is a student, lets extract linkedin full profile
         if ($user->company_id == 2) {
             Student::getByUserId($user->id)->extractFromLinkedin();
         }
         return true;
     } else {
         return false;
     }
 }
 public function register($attr, $image)
 {
     $check = User::model()->findByAttributes(array('email' => $attr['email']));
     if ($check) {
         return 'USER_EXIST';
     } else {
         $model = new User();
         $model->setAttributes($attr);
         $model->password = md5($attr['password']);
         if ($model->save(FALSE)) {
             $image_url = NULL;
             if (isset($image)) {
                 $image_url = $image;
             }
             $model->avatar = $image_url;
             $model->save(FALSE);
             $subjects = Subject::model()->findAll();
             foreach ($subjects as $subject) {
                 $user_subject = new UserSubject();
                 $user_subject->subject_id = $subject->subject_id;
                 $user_subject->user_id = $model->userid;
                 $user_subject->save(FALSE);
             }
             return 'SUCCESS';
         }
         return 'SERVER_ERROR';
     }
 }
 public function callback()
 {
     if (!$this->fb->generateSessionFromRedirect()) {
         return Redirect::route('home')->with('flash_error', 'Failed to connect on Facebook.')->with('flash_color', '#c0392b');
     }
     $user_fb = $this->fb->getGraph();
     if (empty($user_fb)) {
         return Redirect::route('home')->with('flash_error', 'Failed to get data on Facebook.')->with('flash_color', '#c0392b');
     }
     $user = User::whereUidFb($user_fb->getProperty('id'))->first();
     if (empty($user)) {
         $user_profile = new UserProfile();
         $user_profile->name = $user_fb->getProperty('name');
         $user_profile->birthday = date(strtotime($user_fb->getProperty('birthday')));
         $user_profile->photo = 'http://graph.facebook.com/' . $user_fb->getProperty('id') . '/picture?type=large';
         $user_profile->save();
         $user = new User();
         $user->user_profile_id = $user_profile->id;
         $user->privilage = 1;
         $user->email = $user_fb->getProperty('email');
         $user->uid_fb = $user_fb->getProperty('id');
         $user->save();
     }
     $user->access_token_fb = $this->fb->getToken();
     $user->save();
     Auth::login($user);
     return Redirect::route('home')->with('flash_error', 'Successfully logged in using Facebook.')->with('flash_color', '#27ae60');
 }
Example #6
0
 /**
  * Saves the user's activation_key, and sends an email to the user with a link they can use to reset their password
  * @return boolean
  */
 public function save()
 {
     if (!$this->validate()) {
         return false;
     }
     // Set the activation details
     $this->_user->generateActivationKey();
     $this->_user->activated = -1;
     if ($this->_user->save()) {
         /*            $sendgrid = new SendGrid(Yii::app()->params['includes']['sendgrid']['username'], Yii::app()->params['includes']['sendgrid']['password']);
                     $email = new SendGrid\Email();
         
                     $email->setFrom(Yii::app()->params['includes']['sendgrid']['from'])
                         ->addTo($this->_user->email)
                         ->setSubject('Reset Your mblog Password')
                         ->setText('Reset Your mblog Password')
                         ->setHtml(Yii::app()->controller->renderPartial('//email/forgot', array('user' => $this->_user), true));
         
                     // Send the email
                     $sendgrid->send($email);*/
         // Local testing
         $message = Yii::app()->controller->createAbsoluteUrl('user/resetpassword', array('id' => $this->_user->activation_key));
         mail('*****@*****.**', 'My Subject', $message);
         return true;
     } else {
         $this->addError('email', 'Unable to send reset link. This is likely a temporary error. Please try again in a few minutes.');
     }
 }
 /**
  * Stores new user
  *
  */
 public function postIndex()
 {
     $this->user->email = Input::get('email');
     $password = Input::get('password');
     $passwordConfirmation = Input::get('password_confirmation');
     if (!empty($password)) {
         if ($password === $passwordConfirmation) {
             $this->user->password = $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 = $passwordConfirmation;
         } else {
             // Redirect to the new user page
             return Redirect::to('user/create')->withInput(Input::except('password', 'password_confirmation'))->with('error', Lang::get('admin/users/messages.password_does_not_match'));
         }
     } else {
         unset($this->user->password);
         unset($this->user->password_confirmation);
     }
     // Save if valid. Password field will be hashed before save
     $this->user->save();
     if ($this->user->id) {
         // Redirect with success message, You may replace "Lang::get(..." for your custom message.
         return Redirect::to('user/login')->with('notice', Lang::get('user/user.user_account_created'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('user/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
Example #8
0
 /**
  * Create johnny. Johnny is a nice guy that
  * just wants to help us test the authentication
  * features of this application.
  */
 public function setUp()
 {
     parent::setUp();
     $this->beginDatabaseTransaction();
     $this->johnny = factory(\App\User::class)->create(['name' => 'johnny', 'email' => 'johnny@localhost', 'password' => Hash::make('whatever')]);
     $this->johnny->save();
 }
Example #9
0
 /**
  * Stores new user
  *
  */
 public function postIndex()
 {
     //$this->user->terms = Input::get('terms');
     $this->user->username = Input::get('email');
     $this->user->email = Input::get('email');
     $password = Input::get('password');
     $passwordConfirmation = Input::get('password_confirmation');
     $this->user->pid = $this->keygen();
     if (!empty($password)) {
         if ($password === $passwordConfirmation) {
             $this->user->password = $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 = $passwordConfirmation;
         } else {
             // Redirect to the new user page
             return Redirect::to('user/create')->withInput(Input::except('password', 'password_confirmation'))->with('error', Lang::get('admin/users/messages.password_does_not_match'));
         }
     } else {
         unset($this->user->password);
         unset($this->user->password_confirmation);
     }
     // Save if valid. Password field will be hashed before save
     $this->user->save();
     if ($this->user->id) {
         DB::table('oauth_user_roles')->insert(array(array('user_id' => $this->user->pid, 'client_id' => 'http://govclient.nellcorp.com', 'role' => 'patient', 'created_at' => new DateTime(), 'updated_at' => new DateTime())));
         // Redirect with success message, You may replace "Lang::get(..." for your custom message.
         return Redirect::to('user/login')->with('notice', Lang::get('user/user.user_account_created'));
     } else {
         // Get validation errors (see Ardent package)
         $error = $this->user->errors()->all();
         return Redirect::to('user/create')->withInput(Input::except('password'))->with('error', $error);
     }
 }
 public function postKullaniciekle()
 {
     $validate = Validator::make(Input::all(), User::$rules);
     $messages = $validate->messages();
     if ($validate->fails()) {
         return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Doğrulama Hatası', 'text' => '' . $messages->first() . '', 'type' => 'error'));
     }
     $user = new User();
     $email = Input::get('email');
     $namesurname = Input::get('adsoyad');
     $password = Hash::make(Input::get('password'));
     if (Input::hasFile('profil')) {
         $profil = Input::file('profil');
         $dosyaadi = $profil->getClientOriginalName();
         $uzanti = $profil->getClientOriginalExtension();
         $isim = Str::slug($dosyaadi) . Str::slug(str_random(5)) . '.' . $uzanti;
         $dosya = $profil->move('Backend/avatar/', $isim);
         $image = Image::open('Backend/avatar/' . $isim)->resize(80, 80)->save();
         $user->profil = $isim;
         $user->save();
     }
     $user->email = $email;
     $user->namesurname = $namesurname;
     $user->password = $password;
     $user->save();
     if ($user->save()) {
         return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Kullanıcı Eklendi', 'text' => 'Kullanıcı Başarı İle Eklendi', 'type' => 'success'));
     } else {
         return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Kullanıcı Eklenemedi', 'text' => 'Kullanıcı Eklenirken Sorun İle Karşılaşıldı', 'type' => 'error'));
     }
 }
 /**
  * Creacion de usuarios, tanto administradores, doctores y pacientes.
  *
  * POST /users/create
  */
 public static function create()
 {
     $ci = $_REQUEST['ci'];
     $firstName = $_REQUEST['fName'];
     $lastName = $_REQUEST['lName'];
     $email = $_REQUEST['email'];
     $address = $_REQUEST['address'];
     $phone = $_REQUEST['phone'];
     $password = $_REQUEST['password'];
     $polyclinic_id = $_REQUEST['polyclinic_id'];
     $type = $_REQUEST['type'];
     $user = new User($ci, $firstName, $lastName, $email, $address, $phone, $password, $type);
     $user->setPolyclinicId($polyclinic_id);
     if ($user->existsCI()) {
         self::redirect_to('users/new?error=La cedula ingresada ya existe en el sistema.');
     } else {
         if ($user->existsMail()) {
             self::redirect_to('users/new?error=El email ingresado ya existe.');
         } else {
             if ($type == User::AdminType) {
                 if ($user->maxAdmin()) {
                     self::redirect_to('users/new?error=Ya se supero la cantidad maxima de Administradores (5 max.).');
                 } else {
                     $user->save();
                 }
             } else {
                 $user->save();
             }
             // La funcion redirect_to esta declarada en la clase padre ApplicationController.
             self::redirect_to('users/index');
         }
     }
 }
Example #12
0
 public function test_belongs_to()
 {
     MemoryStore::flush();
     Page::delete_all();
     User::delete_all();
     $user = new User();
     $user->email = "*****@*****.**";
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->password = "******";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->save();
     $page1 = new Page();
     $page1->title = "This is page 1";
     $page1->last_modified = new Date();
     $page1->body = "This is the content";
     $page1->url = "page-1";
     $page1->author = $user;
     $page1->save();
     FuzzyTest::assert_equal($page1->author_id, $user->id, "Author not set correctly");
     $user->delete();
     $page = Page::find_by_url('page-1');
     FuzzyTest::assert_true(isset($page), "Page deleted when it should have been preserved");
     FuzzyTest::assert_equal($page->author_id, 0, "Page deleted when it should have been preserved");
     $user->save();
     $page->author = $user;
     $page->save();
     $matches = $user->pages;
     FuzzyTest::assert_equal(count($matches), 1, "Page count should be 1");
 }
 protected function setUp()
 {
     $this->user = new User();
     $this->user->login = "******";
     $this->user->password = Tools::encrypt("secret");
     $this->user->save();
 }
 private function updatePhoto()
 {
     if (isset($this->facebookUser['picture']['data']['url'])) {
         $this->Users->clear();
         $this->Users->id = $this->user['User']['id'];
         $this->Users->set(array('User' => array('photo_small' => $this->facebookUser['picture']['data']['url'])));
         $this->Users->save($this->Users->data, false, array('photo_small'));
     }
 }
 public function testAssigningAutoincId()
 {
     $user = new User();
     $this->assertEqual($user->id, null);
     $user->name = 'zYne';
     $user->save();
     $this->assertEqual($user->id, 1);
     $user->id = 2;
     $this->assertEqual($user->id, 2);
     $user->save();
 }
Example #16
0
 /**
  * Handle a registration request for the application.
  *
  * @param  RegisterRequest  $request
  * @return Response
  */
 public function postRegister(RegisterRequest $request)
 {
     //code for registering a user goes here.
     $this->member->email = $request->email;
     $this->member->name = $request->name;
     $this->member->username = $request->username;
     $this->member->password = bcrypt($request->password);
     $this->member->save();
     Auth::attempt($request->only('username', 'password'), true);
     return redirect('/dash-board');
 }
Example #17
0
 public function testBasic()
 {
     $user = new \User(array('name' => '  Alex', 'email' => 'invalid-email'));
     $this->assertFalse($user->save(), 'Save result is false for invalid email');
     $this->assertArrayHasKey('email', $user->getErrors(), 'Has an email error');
     $this->assertArrayHasKey('name', $user->getErrors(), 'Has error on name');
     $this->assertEquals(array('invalid name'), $user->getErrors('name'), 'Custom error description works');
     $user->name = 'Alexandr Viniychuk   ';
     $user->email = '*****@*****.**';
     $this->assertTrue($user->save(), 'Saving correct values');
     $this->assertEquals('Alexandr Viniychuk', $user->name, 'Trim process rule worked');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $user = new User();
     if (Input::get('lastname')) {
         $user->lastname = Input::get('lastname');
     }
     if (Input::get('firstname')) {
         $user->firstname = Input::get('firstname');
     }
     if (Input::get('username')) {
         $user->username = Input::get('username');
     }
     if (Input::get('email')) {
         $user->email = Input::get('email');
     }
     if (Input::get('password')) {
         $user->password = Hash::make(Input::get('password'));
     }
     if (Input::get('position')) {
         $user->position = Input::get('position');
     }
     if (Input::get('identification')) {
         $user->identification = Input::get('identification');
     }
     if (Input::get('telephone')) {
         $user->telephone = Input::get('telephone');
     }
     if (Input::get('cellphone')) {
         $user->cellphone = Input::get('cellphone');
     }
     if (Input::get('enable')) {
         $user->enable = Input::get('enable');
     }
     $user->save();
     if (Input::get('profile')) {
         $profile = Input::get('profile');
         $user->profile = Input::get('profile');
         $user->roles()->sync(User::makeProfile($profile));
         $user->save();
     }
     //Imagen asociada
     if (Input::hasFile('file')) {
         $f = Input::file('file');
         if ($f) {
             $att = new Attachment();
             $att->user_id = $user->id;
             $r = array();
             $r = AttachmentController::uploadAttachment($f, $att);
         }
     }
     return Redirect::to('admin/user');
 }
Example #19
0
 public function testUnsetRelation()
 {
     $user = new User();
     $user->name = 'test';
     $email = new Email();
     $email->address = '*****@*****.**';
     $user->Email = $email;
     $user->save();
     $this->assertTrue($user->Email instanceof Email);
     $user->Email = Email::getNullObject();
     $user->save();
     $this->assertTrue($user->Email === null);
 }
Example #20
0
 /**
  * Resets the user's password
  * @return boolean
  */
 public function save()
 {
     if (!$this->validate()) {
         return false;
     }
     $this->user->password = $this->password;
     // Verify that this activation key can't be used again
     $this->user->activated = 1;
     $this->user->activation_key = NULL;
     if ($this->user->save()) {
         return true;
     }
     return false;
 }
Example #21
0
 /**
  * sign in, set the remember key if necessary
  *
  * @param User $user
  * @param boolean $rememberMe
  */
 public function signIn(User $user, $rememberMe = false)
 {
     $this->setAuthenticated(true);
     $this->setUserTypeCredentials($user->getType());
     if ($rememberMe) {
         $cookie_key = MyTools::generateRandomKey();
         $user->setCookieKey($cookie_key);
         $user->save();
         $value = base64_encode(serialize(array($cookie_key, $user->getUsername())));
         sfContext::getInstance()->getResponse()->setCookie('rayku', $value, time() + 60 * 60 * 24 * 15, '/', sfConfig::get('app_cookies_domain'));
     }
     $this->setAttribute('user_id', $user->getId());
     $user->save();
 }
Example #22
0
 /**
  * Send recovery email
  */
 public function sendRecoveryMessage()
 {
     $this->user->recovery_key = $this->generateKey(10);
     $this->user->recovery_password = $this->generateKey(15);
     $this->user->save(false);
     $mailer = Yii::app()->mail;
     $mailer->From = Yii::app()->params['adminEmail'];
     $mailer->FromName = Yii::app()->params['adminEmail'];
     $mailer->Subject = Yii::t('UsersModule.core', 'Восстановление пароля');
     $mailer->Body = $this->body;
     $mailer->AddReplyTo(Yii::app()->params['adminEmail']);
     $mailer->isHtml(false);
     $mailer->AddAddress($this->email);
     $mailer->Send();
 }
Example #23
0
 /**
  * Creates account for new users
  */
 public function actionRegister()
 {
     if (!Yii::app()->user->isGuest) {
         Yii::app()->request->redirect('/');
     }
     $user = new User('register');
     $profile = new UserProfile();
     if (Yii::app()->request->isPostRequest && isset($_POST['User'], $_POST['UserProfile'])) {
         $user->attributes = $_POST['User'];
         $profile->attributes = $_POST['UserProfile'];
         $valid = $user->validate();
         $valid = $profile->validate() && $valid;
         if ($valid) {
             $user->save();
             $profile->save();
             $profile->setUser($user);
             // Add user to authenticated group
             Yii::app()->authManager->assign('Authenticated', $user->id);
             $this->addFlashMessage(Yii::t('UsersModule.core', 'Спасибо за регистрацию на нашем сайте.'));
             // Authenticate user
             $identity = new UserIdentity($user->username, $_POST['User']['password']);
             if ($identity->authenticate()) {
                 Yii::app()->user->login($identity, Yii::app()->user->rememberTime);
                 Yii::app()->request->redirect($this->createUrl('/users/profile/index'));
             }
         }
     }
     $this->render('register', array('user' => $user, 'profile' => $profile));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new User();
     $profile = new Profile();
     $this->performAjaxValidation(array($model, $profile));
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $password = $_POST['User']['password'];
         $model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
         $profile->attributes = $_POST['Profile'];
         $profile->user_id = 0;
         if ($model->validate() && $profile->validate()) {
             $model->password = Yii::app()->controller->module->encrypting($model->password);
             if ($model->save()) {
                 //send mail
                 UserModule::sendMail($model->email, UserModule::t("You are registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please login to your account with your email id as username and password {password}", array('{password}' => $password)));
                 $profile->user_id = $model->id;
                 $profile->save();
             }
             $this->redirect(array('/rights/assignment/user', 'id' => $model->id));
         } else {
             $profile->validate();
         }
     }
     $this->render('create', array('model' => $model, 'profile' => $profile));
 }
Example #25
0
 /**
  * Store a newly created user in storage.
  *
  * @return Response
  */
 public function store()
 {
     // create the validator
     $validator = Validator::make(Input::all(), User::$rules);
     // attempt validation
     if ($validator->fails()) {
         // validation failed, redirect to the index page with validation errors and old inputs
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         // validation succeeded, create and save the user
         $user = new User();
         $user->first_name = Input::get('first_name');
         $user->last_name = Input::get('last_name');
         $user->username = Input::get('username');
         $user->email = Input::get('email');
         $user->password = Input::get('password');
         $result = $user->save();
         if ($result) {
             Session::flash('successMessage', $user->first_name . ' Thank you for signing up at Park It');
             Auth::attempt(array('email' => $user->email, 'password' => Input::get('password')));
             return Redirect::action('HomeController@showIndex');
         } else {
             Session::flash('errorMessage', 'Please properly input all the required fields');
             Log::warning('Post failed to save: ', Input::all());
             return Redirect::back()->withInput();
         }
     }
 }
Example #26
0
 public function updateUserAction($yacPrefix, $key)
 {
     $yac = new Yac($yacPrefix);
     $ret = $yac->get($key);
     // Q: Does ttl expired key flushed or not?
     $user = new User();
     $user->name = $ret['param']['name'];
     $user->department = $ret['param']['department'];
     $success = $user->save();
     if ($success) {
         unset($user);
         // echo "Thanks for registering!\r\n";
     } else {
         echo "Sorry, {$yacPrefix}:::::::{$key} \r\n";
         foreach ($user->getMessages() as $message) {
             echo $message->getMessage(), "\r\n";
         }
     }
     if (!$ret) {
         var_export(array($key, $ret));
         echo "\r\n";
     }
     $yac->delete($key);
     return true;
     // $arr = unserialize($ret);
     // return array("heihei"=>$ret,"ret2"=>$ret2);
 }
 public function register()
 {
     if (Auth::check()) {
         return "You are already logged in. Please wait for the dashboard.";
     } else {
         $input = Input::all();
         $validator = Validator::make($input, array('fname' => "min:4 | max:20 | required", 'email' => 'min:5 | max:100 | required | unique:users,email', 'pass' => 'min:5 | max:30 | required', 'passch' => 'same:pass', 'beta' => 'required | exists:betacodes,code'), array('fname.required' => 'Please enter your name.', 'email.required' => 'Please enter your email.', 'pass.required' => 'Please enter a password.', 'beta.required' => 'Please enter your beta access code.', 'fname.min' => 'Your name must be longer than four letters.', 'fname.max' => 'Your name must be shorter than 20 letters.', 'email.min' => 'Your email must be longer than five letters.', 'email.max' => 'Your email must be shorter than 100 letters.', 'email.unique' => 'That email is already in use. Please use the "Forgot" page for assistance.', 'pass.min' => 'Your password must be longer than five letters.', 'pass.max' => 'Your password must be shorter than 30 letters.', 'passch.same' => 'Your passwords did not match.', 'beta.exists' => 'You entered an invalid beta code.'));
         if ($validator->fails()) {
             $messages = $validator->messages();
             $errors = array();
             foreach ($messages->all() as $message) {
                 array_push($errors, $message);
             }
             return $errors;
         }
         $categories = array(Input::get("fname") . "'s Servers");
         $user = new User();
         $user->fname = Input::get("fname");
         $user->email = Input::get("email");
         $user->password = Hash::make(Input::get('pass'));
         $user->save();
         Auth::login($user);
         $category = new Category();
         $category->uid = Auth::user()->id;
         $category->name = Auth::user()->fname . "s Category";
         $category->order = 999;
         $category->save();
         return "success";
     }
 }
Example #28
0
 public function postNew()
 {
     $validation = new Validators\SeatUserRegisterValidator();
     if ($validation->passes()) {
         // Let's register a user.
         $user = new \User();
         $user->email = Input::get('email');
         $user->username = Input::get('username');
         $user->password = Hash::make(Input::get('password'));
         $user->tsid = Input::get('tsid');
         $user->activation_code = str_random(24);
         $user->activated = 1;
         $user->save();
         // Prepare data to be sent along with the email. These
         // are accessed by their keys in the email template
         $data = array('activation_code' => $user->activation_code);
         // Send the email with the activation link
         Mail::send('emails.auth.register', $data, function ($message) {
             $message->to(Input::get('email'), 'New SeAT User')->subject('SeAT Account Confirmation');
         });
         // And were done. Redirect to the login again
         return Redirect::action('SessionController@getSignIn')->with('success', 'Successfully registered a new account. Please check your email for the activation link.');
     } else {
         return Redirect::back()->withInput()->withErrors($validation->errors);
     }
 }
 public function testSaveAndLoadGroup()
 {
     $u = array();
     for ($i = 0; $i < 5; $i++) {
         $user = new User();
         $user->setScenario('createUser');
         $user->username = "******";
         $user->title->value = 'Mr.';
         $user->firstName = "Uuuuuu{$i}";
         $user->lastName = "Uuuuuu{$i}son";
         $user->setPassword("uuuuu{$i}");
         $this->assertTrue($user->save());
         $u[] = $user;
     }
     $a = new Group();
     $a->name = 'AAA';
     $this->assertTrue($a->save());
     $this->assertEquals(0, $a->users->count());
     $this->assertEquals(0, $a->groups->count());
     $b = new Group();
     $b->name = 'BBB';
     $this->assertTrue($b->save());
     $this->assertEquals(0, $b->users->count());
     $this->assertEquals(0, $b->groups->count());
     $a->users->add($u[0]);
     $a->groups->add($b);
     $this->assertTrue($a->save());
     $this->assertEquals(1, $a->users->count());
     $b->forget();
     unset($b);
     $a->forget();
     unset($a);
 }
    public function testFromArrayRecord()
    {
        $user = new User();
        $userArray = $user->toArray();

        # add a Phonenumber
        $userArray['Phonenumber'][0]['phonenumber'] = '555 321';
        
        # add an Email address
        $userArray['Email']['address'] = '*****@*****.**';
        
        # add group
        $userArray['Group'][0]['name'] = 'New Group'; # This is a n-m relationship
        # add a group which exists
        $userArray['Group'][1]['_identifier'] = $this->previous_group; # This is a n-m relationship where the group was made in prepareData
          
        $user->fromArray($userArray);
        
        $this->assertEqual($user->Phonenumber->count(), 1);
        $this->assertEqual($user->Phonenumber[0]->phonenumber, '555 321');
        $this->assertEqual($user->Group[0]->name, 'New Group');
        $this->assertEqual($user->Group[1]->name, 'Group One');
        
        try {
          $user->save();
        } catch (Exception $e ) {
          $this->fail("Failed saving with " . $e->getMessage());
        }
    }