Exemplo n.º 1
2
 public function store()
 {
     $data = Input::all();
     if (isset($data['phone_number'])) {
         $data['phone_number'] = str_replace(' ', '', $data['phone_number']);
     }
     if (isset($data['work_phone'])) {
         $data['work_phone'] = str_replace(' ', '', $data['work_phone']);
     }
     $u = new User();
     $a = false;
     $role_id = Input::get('role_id');
     if ($role_id == Config::get('constants.ROLE_BUYER')) {
         $a = new Buyer();
         $u->status = 2;
         $data['skip_verification'] = true;
     } elseif ($role_id == Config::get('constants.ROLE_SELLER')) {
         $a = new Seller();
     } elseif ($role_id == Config::get('constants.ROLE_BROKER')) {
         $a = new Broker();
     } else {
         //we don't know this role or attempt to register unlisted role
         unset($data['role_id']);
     }
     if (!isset($data['password']) || $data['password'] == "") {
         $pwd = Str::random(10);
         $data['password'] = $data['password_confirmation'] = $pwd;
     }
     if ($u->validate($data)) {
         if ($a && $a->validate($data)) {
             if (isset($pwd)) {
                 Session::set('validate_password', true);
             }
             $data['password'] = Hash::make($data['password']);
             $u->fill($data);
             $code = Str::random(10);
             $u->verification_code = $code;
             $data['verification_code'] = $code;
             $u->save();
             $data['user_id'] = $u->id;
             $a->fill($data);
             $a->save();
             $email = $u->email;
             if (isset($data['skip_verification'])) {
                 $data['url']['link'] = url('/');
                 $data['url']['name'] = 'Go to CompanyExchange';
                 Mail::queue('emails.templates.welcome', $data, function ($message) use($email) {
                     $message->from('*****@*****.**', 'CompanyExchange');
                     $message->to($email);
                     $message->subject('Welcome to CompanyExchange');
                 });
             } else {
                 Mail::queue('emails.templates.progress', $data, function ($message) use($email) {
                     $message->from('*****@*****.**', 'CompanyExchange');
                     $message->to($email);
                     $message->subject('Welcome to CompanyExchange');
                 });
             }
             if ($role_id == Config::get('constants.ROLE_BUYER')) {
                 Auth::loginUsingId($u->id);
                 Alert::success('Welcome to CompanyExchange. Please feel free to browse through our listings and contact sellers you would like to buy from.', 'Congratulations');
                 return Redirect::to('search?q=')->withSuccess("Welcome {$u->first_name}. Use the form on the left to search for listed businesses or browse the most recent listings below");
             }
             return Redirect::to('login')->withSuccess('Registration successful. Please check email to activate your account');
         }
         Input::flash();
         return View::make('users.register')->withErrors($a ? $a->getValidator() : []);
     }
     Input::flash();
     return View::make('users.register')->withErrors($u->getValidator());
 }
Exemplo n.º 2
0
 public function createUser()
 {
     $options = $this->option();
     $this->info('Creating the developer account');
     if (!$options['name']) {
         $options['name'] = $this->ask('What is your name?');
     }
     if (!$options['email']) {
         $options['email'] = $this->ask('What is your email?');
     }
     if (!$options['password']) {
         $p1 = ' ';
         $p2 = '';
         while ($p1 !== $p2) {
             $p1 = $this->secret('Type a password');
             $p2 = $this->secret('Repeat the password');
             if ($p1 !== $p2) {
                 $this->error('Passwords doesn\'t match, try again');
             }
         }
         $options['password'] = $p1;
     }
     $user = ['name' => $options['name'], 'email' => $options['email'], 'role' => 'dev'];
     try {
         $model = new \User();
         $model->fill($user);
         $model->password = \Hash::make($options['password']);
         $model->isValid();
         $model->save();
     } catch (\Exception $e) {
         $this->error('Error creating developer user: "******"');
     }
 }
Exemplo n.º 3
0
 public function run()
 {
     $user = new User();
     $user->fill(array('email' => '', 'nickname' => '', 'activated' => '1'));
     $user->password = Hash::make('admin');
     $user->save();
 }
 public function postRegistration()
 {
     if ($this->isPostRequest()) {
         $validator = $this->getRegistrationValidator();
         if ($validator->passes()) {
             $credentials = $this->getRegistrationCredentials();
             $user = new User();
             //Take care, only mass assignable columns are fillable, check User model
             $user->fill($credentials);
             if ($user->save()) {
                 $status = 201;
                 $data = array('status' => $status, 'success' => true, 'message' => 'User sucessfully created');
                 $response = MyResponse::json($data, $status);
                 return $response;
             } else {
                 $status = 200;
                 $data = array('status' => $status, 'success' => false, 'message' => 'User unsucessfully updated');
                 $response = MyResponse::json($data, $status);
                 return $response;
             }
         } else {
             $status = 200;
             $data = array('status' => $status, 'success' => false, 'message' => $validator->messages()->toArray());
             $response = MyResponse::json($data, $status);
             return $response;
         }
     } else {
     }
 }
Exemplo n.º 5
0
 public function saveUser()
 {
     $input = Input::all();
     $input['password'] = Hash::make($input['password']);
     $user = new User();
     $user->fill($input);
     $user->save();
     return $user;
 }
 public function postRegister()
 {
     $rules = User::$validation;
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         return Redirect::to('users/register')->withErrors($validation)->withInput();
     }
     $user = new User();
     $user->fill(Input::all());
     $id = $user->register();
     return $this->getMessage("Регистрация почти завершена. Вам необходимо подтвердить e-mail, указанный при регистрации, перейдя по ссылке в письме.");
 }
Exemplo n.º 7
0
 public function store()
 {
     $data = Input::all()['user'];
     $user = new User();
     if ($user->isValid($data)) {
         $data['password'] = Hash::make($data['password']);
         $user->fill($data);
         $user->save();
         return Redirect::route('users.index');
     }
     return Redirect::route('users.create')->withInput()->withErrors($user->errors);
 }
Exemplo n.º 8
0
 public function postRegister()
 {
     $validator = Validator::make(Input::all(), array('name' => array('required', 'min:5'), 'email' => array('required', 'email', 'unique:users'), 'password' => array('required', 'confirmed')));
     if ($validator->passes()) {
         $user = new User();
         $user->fill(Input::all());
         $id = $user->register();
         return $this->getMessage("Регистрация почти завершена. Вам необходимо подтвердить e-mail, указанный при регистрации, перейдя по ссылке в письме.");
     } else {
         return Redirect::to('auth/register')->with('error', 'Please correct the following errors:')->withErrors($validator)->withInput();
     }
     return;
 }
 public function store()
 {
     // Get form data, create new user
     // Hacky, I know, but had to do this because of Sentry
     $user_data = Input::all();
     $user = new User();
     $user->fill($user_data);
     // TODO:  If we need to do confirmation, then stop doing this below
     $user->confirmed = 1;
     if ($user->save()) {
         return Redirect::to('admin/users/' . $user->id . '/edit')->with('success_message', trans('admin.create_success'));
     } else {
         return Redirect::to('admin/users/create')->withInput(Input::except('password'))->withErrors($user->errors());
     }
 }
Exemplo n.º 10
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $user = new User();
     $user->unguard();
     $user->fill(Input::only('username', 'email', 'password', 'rights', 'first_name', 'last_name', 'student_number'));
     if ($user->validate()) {
         $user->password = Hash::make(Input::get('password'));
         $user->save();
     } else {
         $user->password = null;
         // Don't send the password back over the wire
         return View::make('users.create', ['user' => $user])->withErrors($user->validator());
     }
     return Redirect::to(route('settings.index'))->with('message', ['content' => 'Gebruiker met succes aangemaakt!', 'class' => 'success']);
 }
Exemplo n.º 11
0
 public function action_register()
 {
     $method = Request::method();
     if ($method == 'POST') {
         // get the username and password from the POST
         // data using the Input class
         $username = Input::get('username');
         $email = Input::get('email');
         $password = Input::get('password');
         $role = 1;
         $active = true;
         if (empty($username) || empty($password)) {
             return Redirect::to('account/register')->with('register_errors', true);
         } else {
             $arr = array('username' => $username, 'email' => $email, 'password' => Hash::make($password), 'role' => $role, 'active' => $active);
             $rules = array('username' => 'unique:users,username|required|min:1|max:20', 'password' => 'required', 'email' => 'unique:users,email|required');
             // make the validator
             $v = Validator::make($arr, $rules);
             if ($v->fails()) {
                 // redirect back to the form with
                 // errors, input and our currently
                 // logged in user
                 return Redirect::to('account/register')->with('user', Auth::user())->with_errors($v)->with_input();
             }
             $user = new User();
             $user->fill($arr);
             $result = $user->save();
             // call Auth::attempt() on the username and password
             // to try to login, the session will be created
             // automatically on success
             if ($result) {
                 if (Auth::attempt(array('username' => $username, 'password' => $password, 'remember' => true))) {
                     // it worked, redirect to the admin route
                     return Redirect::to('/');
                 } else {
                     // login failed, show the form again and
                     // use the login_errors data to show that
                     // an error occured
                     return Redirect::to('account/login')->with('login_errors', true);
                 }
             } else {
                 return Redirect::to('account/register')->with('register_errors', true);
             }
         }
     } else {
         return View::make('account.register');
     }
 }
Exemplo n.º 12
0
 public function postRegister()
 {
     // Проверка входных данных
     $data = Input::all();
     $rules = User::$validation;
     $validation = Validator::make($data, $rules);
     if ($validation->fails()) {
         // В случае провала, редиректим обратно с ошибками и самими введенными данными
         return Redirect::to('users/register')->withErrors($validation)->withInput();
     }
     // Сама регистрация с уже проверенными данными
     $user = new User();
     $user->fill($data);
     $id = $user->register();
     // Вывод информационного сообщения об успешности регистрации
     return $this->getMessage("Регистрация почти завершена. Вам необходимо подтвердить e-mail, указанный при регистрации, перейдя по ссылке в письме.");
 }
Exemplo n.º 13
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function getStoreAdmin()
 {
     $inputs = \Input::all();
     $validator = \Validator::make($inputs, ['email' => 'required|email|unique:users', 'password' => 'required|confirmed', 'username' => 'required', 'first_name' => 'required', 'last_name' => 'required']);
     $data = ['username' => $inputs['username'], 'first_name' => $inputs['first_name'], 'last_name' => $inputs['last_name'], 'email' => $inputs['email'], 'password' => $inputs['password'] = Hash::make($inputs['password']), 'confirmation_token' => $inputs['confirmation_token'] = sha1(uniqid($inputs['email'], true))];
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput($data);
     }
     $user = new User();
     $user->fill($data);
     //        $user->is_confirmed = true;
     //        $user->is_admin = (bool)array_get($data, 'is_admin');
     Mail::send('emails.activate', $data, function ($message) use($data) {
         $message->to($data['email'])->subject('Please verify your email address');
     });
     User::create($user);
     //        return Redirect::to('login')->with('alert', 'Sign up successful, Please check your email.');
     return Redirect::route('admin.users.show', ['id' => $user->id])->with('alert-success', 'User was created.');
 }
Exemplo n.º 14
0
 /**
  * Store a newly created user in storage.
  *
  * @return Response
  */
 public function store()
 {
     User::setRules('store');
     $data = Input::all();
     if (!User::canCreate()) {
         return $this->_access_denied();
     }
     $data['confirmed'] = 1;
     $data['roles'] = isset($data['roles']) ? $data['roles'] : [];
     $user = new User();
     $user->fill($data);
     if (!$user->save()) {
         return $this->_validation_error($user);
     }
     $user->roles()->sync($data['roles']);
     if (Request::ajax()) {
         return Response::json($user, 201);
     }
     return Redirect::route('users.index')->with('notification:success', $this->created_message);
 }
Exemplo n.º 15
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //Creamos un nuevo objeto para nuestro nuevo usuario
     $user = new User();
     //return Input::all();
     //Obtenemos la data enviada por el usuario
     $data = Input::all();
     //
     //var_dump($data);
     //Revisamos si la data es valida
     if ($user->isValid($data)) {
         //Si la data es valida se la asignamos al usuario
         $user->fill($data);
         //Guardamos el usuario
         $user->save();
         //Y devolvemos una redirección a la acción show para mostrar el usuario
         return Redirect::route('admin.users.show', array($user->id));
     } else {
         // En caso de error regresa a la acción create con los datos y los errores encontrados
         return Redirect::route('admin.users.create')->withInput()->withErrors($user->errors);
     }
 }
Exemplo n.º 16
0
<?php 
# register.php
# 1. logic
if (Input::posted()) {
    $user = new User();
    $user->fill(Input::all());
    $user->password = password_hash($user->password, PASSWORD_DEFAULT);
    $user->save();
    Auth::log_in($user->id);
    URL::redirect('home');
}
# 2. views
include VIEWS . 'header.php';
include VIEWS . 'register.php';
include VIEWS . 'footer.php';
Exemplo n.º 17
0
 /**
  * Store user account
  * @return Response
  */
 public function storeUser()
 {
     $data = Input::all();
     $u = new User();
     $a = false;
     $role_id = Input::get('role_id');
     if ($role_id == Config::get('constants.ROLE_BUYER')) {
         $a = new Buyer();
         $u->status = 2;
         $data['skip_verification'] = true;
     } elseif ($role_id == Config::get('constants.ROLE_SELLER')) {
         $a = new Seller();
     } elseif ($role_id == Config::get('constants.ROLE_BROKER')) {
         $a = new Broker();
     }
     $data['password_confirmation'] = $data['password'];
     if ($u->validate($data)) {
         if ($a->validate($data)) {
             $data['password'] = Hash::make($data['password']);
             $u->fill($data);
             $u->save();
             $a->fill($data);
             $a->user_id = $u->id;
             $a->save();
             return Redirect::to('admin/accounts')->withCreate(true)->withUsr($u);
         }
         return View::make('admin.users.create')->withErrors($a->getValidator());
     }
     return View::make('admin.users.create')->withErrors($u->getValidator());
 }
Exemplo n.º 18
0
 private function registerUser($data, $role)
 {
     if (isset($data['phone_number'])) {
         $data['phone_number'] = str_replace(' ', '', $data['phone_number']);
     }
     if (isset($data['work_phone'])) {
         $data['work_phone'] = str_replace(' ', '', $data['work_phone']);
     }
     $u = new User();
     $data['role_id'] = $role;
     switch (strtolower($role)) {
         case Config::get('constants.ROLE_SELLER'):
             $a = new Seller();
             break;
         case Config::get('constants.ROLE_BROKER'):
             $a = new Broker();
             break;
         default:
             $a = new Buyer();
             $u->status = 2;
             $data['skip_verification'] = true;
             break;
     }
     if (!isset($data['password']) || $data['password'] == "") {
         $pwd = Str::random(10);
         $data['password'] = $data['password_confirmation'] = $pwd;
     }
     if ($u->validate($data)) {
         if ($a->validate($data)) {
             if (isset($pwd)) {
                 Session::set('validate_password', true);
             }
             $data['password'] = Hash::make($data['password']);
             $u->fill($data);
             $code = Str::random(10);
             $u->verification_code = $code;
             $data['verification_code'] = $code;
             $u->save();
             $data['user_id'] = $u->id;
             $a->fill($data);
             $a->save();
             $email = $u->email;
             if (isset($data['skip_verification'])) {
                 $data['url']['link'] = url('/');
                 $data['url']['name'] = 'Go to CompanyExchange';
                 Mail::queue('emails.templates.welcome', $data, function ($message) use($email) {
                     $message->from('*****@*****.**', 'CompanyExchange');
                     $message->to($email);
                     $message->subject('Welcome to CompanyExchange');
                 });
             } else {
                 Mail::queue('emails.templates.progress', $data, function ($message) use($email) {
                     $message->from('*****@*****.**', 'CompanyExchange');
                     $message->to($email);
                     $message->subject('Welcome to CompanyExchange');
                 });
             }
             Auth::loginUsingId($u->id);
             return true;
         }
         Input::flash();
         return $a->getValidator();
     }
     Input::flash();
     return $u->getValidator();
 }
Exemplo n.º 19
0
 * Signup
 */
Route::get('(:bundle)/signup', array('as' => 'auth_signup', 'before' => 'users', 'do' => function () {
    return View::make('layout')->with('title', 'Signup')->nest(Config::get('authvel::content'), 'authvel::signup');
}));
Route::post('(:bundle)/signup', array('as' => 'auth_signup_post', 'before' => 'users', 'do' => function () {
    $rules = array('email' => 'required|email|unique:users,email');
    $validation = Validator::make(Input::all(), $rules);
    if ($validation->fails()) {
        return Redirect::to_route('auth_signup')->with_errors($validation);
    } else {
        $email = Input::get('email');
        $username = strstr($email, '@', TRUE) . rand(1000, 9999);
        $password = randString(6, TRUE);
        $user = new User();
        $user->fill(array('username' => $username, 'password' => $password, 'email' => $email, 'access' => 0));
        $user->save();
        Auth::login($user->id);
        return Redirect::to_route('auth_lobby');
    }
}));
/**
 * Logout
 */
Route::get('(:bundle)/logout', array('as' => 'auth_logout', 'before' => 'guests', 'do' => function () {
    Auth::logout();
    return Redirect::to_route('auth_lobby');
}));
/**
 * Settings
 */
Exemplo n.º 20
0
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), User::$rules);
     $data = Input::all();
     if ($validator->passes()) {
         $user = new User();
         $oldFileName = $user->photo;
         $user->fill($data);
         if (Input::hasFile('photo')) {
             // Get the image input
             $file = Input::file('photo');
             // Save image and crop it
             $photoName = Client::saveImg($file);
             // Store photos name
             $user->photo = $photoName;
         } else {
             $user->photo = $oldFileName;
         }
         $user->password = Hash::make(Input::get('password'));
         $user->birthdate = date("Y-m-d", strtotime(Input::get('birthdate')));
         $user->save();
         return Redirect::to('home')->with('confirmation', '¡Gracias por registrarte, tu perfil sera validado por un administrador!');
     } else {
         // validation has failed, display error messages
         return Redirect::to(Input::get('url'))->with('message', 'Debes corregir los siguientes campos:')->withErrors($validator)->withInput();
     }
 }
Exemplo n.º 21
0
    } else {
        $userData = array("username" => $user_data["info"]["nickname"], 'verified' => 1, "email" => isset($user_data["info"]["email"]) ? $user_data["info"]["email"] : null);
        if ($user_data["provider"] == "twitter") {
            $userData["email"] = $user_data["info"]["nickname"] . "@fillme.twitter";
            $userData["twitter_url"] = $user_data["info"]["urls"]["twitter"];
        } elseif ($user_data["provider"] == "github") {
            $userData["github_url"] = $user_data["info"]["urls"]["github"];
        } elseif ($user_data["provider"] == "google") {
            $userData["googleplus_url"] = $user_data["info"]["urls"]["googleplus"];
        }
        $originalUname = $userData['username'];
        for ($i = 1; User::where_username($userData['username'])->count() > 0; $i++) {
            $userData['username'] = $originalUname . '-' . $i++;
        }
        $user = new User();
        $user->fill($userData, true);
        $user->save();
        $client->user_id = $user->id;
        $client->save();
        Auth::login($user->id, true);
    }
});
Event::listen('oneauth.sync', function ($user_id) {
    OneAuth\Auth\Core::sync($user_id);
});
Event::listen('laravel.auth: login', function () {
    $user = IoC::resolve('oneauth.driver: auth.user');
    Event::fire('oneauth.sync', array($user->id));
});
Event::listen('laravel.auth: logout', function () {
    Session::forget('oneauth');
Exemplo n.º 22
0
 /**
  * Add a new user
  *
  * @param  array  $info
  * @return array
  */
 public static function add_user($info)
 {
     $rules = array('firstname' => array('required', 'max:50'), 'lastname' => array('required', 'max:50'), 'email' => array('required', 'email', 'unique:users'));
     $validator = Validator::make($info, $rules);
     if ($validator->fails()) {
         return array('success' => false, 'errors' => $validator->errors);
     }
     $insert = array('email' => $info['email'], 'firstname' => $info['firstname'], 'lastname' => $info['lastname'], 'role_id' => $info['role_id'], 'password' => Hash::make($password = Str::random(6)));
     $user = new User();
     $user->fill($insert)->save();
     /* Send Activation email */
     $view = View::make('email.new_user', array('email' => $info['email'], 'password' => $password));
     //Mail::send_email($view, $info['email'], 'Your Tiny Issue Account');
     Mail::send_email($view, $info['email'], __('email.subject_newuser'));
     return array('success' => true, 'password' => $password);
 }
Exemplo n.º 23
0
 public function store()
 {
     $rules = ['first_name' => 'AlphaNum', 'last_name' => 'AlphaNum', 'email' => 'Required|Email', 'customLoginName' => 'AlphaNum|Unique:users', 'address' => 'AlphaNum', 'phone' => 'AlphaNum', 'cellphone' => 'AlphaNum', 'password' => 'AlphaNum|Min:6|Max:120|Confirmed'];
     $v = Validator::make(Input::all(), $rules);
     if ($v->passes()) {
         $user = new User();
         $user->fill(Input::all());
         $user->password = Hash::make(Input::get('password'));
         $user->save();
         return Redirect::action('UserController@index');
     } else {
         return Redirect::action('UserController@create')->withErrors($v->getMessageBag());
     }
 }
Exemplo n.º 24
0
    $page->content = Input::get('content');
    $page->publish = Input::get('publish');
    $page->save();
    return Redirect::to('admin/pages');
}), 'POST /admin/newmedia' => array('before' => 'auth', function () {
    $imagename = time() . Input::file('image.name');
    File::upload('image', PUBLIC_PATH . 'img/' . $imagename);
    $newimage = PUBLIC_PATH . 'img/' . $imagename;
    $image = new Imagick($newimage);
    $image->scaleImage(400, 0);
    $image->writeImage(PUBLIC_PATH . 'img/medium_' . $imagename);
    $image->resizeImage(80, 80, Imagick::FILTER_LANCZOS, 1, TRUE);
    $image->writeImage(PUBLIC_PATH . 'img/thumb_' . $imagename);
    $image->destroy();
    $media = new Media();
    $media->filename = $imagename;
    $media->caption = Input::get('caption');
    $media->meta = Input::get('meta');
    $media->save();
    return Redirect::to('admin/media');
}), 'POST /admin/newuser' => array('before' => 'auth', function () {
    $rules = array('firstname' => 'required|max:140', 'lastname' => 'required|max:140', 'email' => 'required|max:50|unique:users', 'role' => 'required', 'password' => 'required|max:50|between:6,16|confirmed');
    $validator = Validator::make(Input::get(), $rules);
    if (!$validator->valid()) {
        return Redirect::to('admin/newuser')->with('errors', $validator->errors)->with_input('except', array('password', 'password_confirmation'));
    }
    $user = new User();
    $user->fill(array('firstname' => Input::get('firstname'), 'lastname' => Input::get('lastname'), 'email' => Input::get('email'), 'role' => Input::get('role'), 'password' => Hash::make(Input::get('password'))));
    $user->save();
    return Redirect::to('admin');
}));
Exemplo n.º 25
0
 public function postRegister()
 {
     $rules = User::$validation;
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         return Redirect::to('/register')->withErrors($validation)->withInput();
     }
     $user = new User();
     $user->fill(Input::all());
     $id = $user->register();
     $member = new Member();
     $member->user_id = $id;
     $member->save();
     $redir = action('IndexController@getIndex');
     return $this->getMessage("Регистрация почти завершена. Вам необходимо подтвердить e-mail, указанный при регистрации, перейдя по ссылке в письме.", $redir, "Завершение регистрации");
 }