本文整理汇总了PHP中Users::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::create方法的具体用法?PHP Users::create怎么用?PHP Users::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUserAction
public function createUserAction()
{
$this->view->disable();
$inputData = $this->request->getJsonRawBody();
$messages = Users::getValidator()->validate($inputData);
if (count($messages)) {
$errors = [];
foreach ($messages as $message) {
$errors[] = ['message' => $message->getMessage(), 'field' => $message->getField()];
}
$this->response->setJsonContent(['status' => 'error', 'data' => $errors]);
$this->response->setStatusCode(401, 'validation fail');
$this->response->send();
} else {
$user = new Users();
$user->firstName = $inputData->firstName;
$user->lastName = $inputData->lastName;
$user->email = $inputData->email;
$user->password = md5($inputData->password);
$user->gender = $inputData->gender;
$user->details = $inputData->details;
$user->hobby = serialize($inputData->hobby);
if ($inputData->image->filetype == 'image/jpeg') {
$user->fileName = '.jpg';
} else {
$user->fileName = '.png';
}
$user->create();
file_put_contents('files/' . $user->id . $user->fileName, base64_decode($inputData->image->base64));
$this->response->setJsonContent(['status' => 'success', 'data' => 'user added']);
$this->response->setStatusCode(200, "OK");
$this->response->send();
}
}
示例2: run
/** * Run the database seeds. * * @return void */
public function run()
{
DB::table('users')->delete();
Users::create(['id' => 1210311232, 'name' => '李锐', 'password' => Hash::make('1210311232')]);
Users::create(['id' => 1210311233, 'name' => '陈曦', 'password' => Hash::make('1210311233')]);
Users::create(['id' => 1234567890, 'name' => '管理员', 'password' => Hash::make('root'), 'is_admin' => 1]);
}
示例3: upAction
/**
* Registration
*/
public function upAction()
{
if ($this->request->isPost()) {
$user = new Users();
$user->login = $this->request->getPost('login', 'string');
$user->password = $this->request->getPost('password', 'string');
$passwordVerify = $this->request->getPost('password-verify', 'string');
if (md5($user->password) !== md5($passwordVerify)) {
$this->flashSession->error('Пароли не совпадают');
return;
}
if (!$user->create()) {
$this->flashSession->error(implode("<br/>", $user->getMessages()));
return;
}
$auth = new Auth();
$authSucceed = $auth->authorize($user);
if ($authSucceed) {
$this->response->redirect();
return;
}
$this->dispatcher->forward(['controller' => 'sign', 'action' => 'in']);
return;
}
}
示例4: postAction
public function postAction()
{
$this->getConnectedUser()->assertRight('user_create');
if (Users::exists($_POST['user_login'])) {
throw new Knb_Error("An user with the name {${$_POST['user_login']}} already exists");
}
Users::create($_POST);
}
示例5: getKlantByID
public function getKlantByID($idklant)
{
$sql = "select * from klant where idklant = :idklant";
$dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD);
$stmt = $dbh->prepare($sql);
$stmt->execute(array(':idklant' => $idklant));
$rij = $stmt->fetch(PDO::FETCH_ASSOC);
$klanten = Users::create($rij["idklant"], $rij["naam"], $rij["voornaam"], $rij["straat"], $rij["nr"], $rij["postcode"], $rij["gemeente"], $rij["email"]);
$dbh = null;
return $klanten;
}
示例6: post_create
public function post_create()
{
$rules = array('userEmail' => 'required|email|max:60', 'userPassword' => 'required|max:60');
$validation = Validator::make(Input::get(), $rules);
if ($validation->fails()) {
return Redirect::to('admin/users');
}
$email = Input::get('userEmail');
$password = Input::get('userPassword');
Users::create($email, $password);
return Redirect::to('admin/users');
}
示例7: process
public function process()
{
$user = new Users();
$salt = Hash::salt(32);
//generate some tandom salt
try {
$user->create(array('userid' => Input::get('res-id'), 'password' => Hash::make(Input::get('res-pass'), $salt), 'salt' => $salt, 'joined' => date('Y-m-d H:i:s')));
return 1;
} catch (Exception $e) {
return 0;
}
}
示例8: register
public function register()
{
include_once "models/Users.php";
$users = new Users();
$result = $users->create();
if ($result) {
$_SESSION["user"] = serialize($users);
header("Location: dashboard");
} else {
$error = "register";
header("Location: login?error=" . $error);
}
}
示例9: getUser
/**
* getUser
* Get user info from db or save fb data to db
*
* @param array $fb_user returned by FB request
*
* @return object
**/
function getUser($fb_user)
{
// check user exists in DB
$user = Users::findOne($fb_user['id']);
if (!$user) {
// save user info
$user = Users::create();
$user->id = $fb_user['id'];
$user->name = $fb_user['name'];
$user->email = $fb_user['email'];
$user->save();
}
return $user;
}
示例10: CreateUser
function CreateUser($data, $fields)
{
try {
$User = new Users();
$result = $User->create($fields);
$this->domain->addDomainValue('CREATED', $User->getUsrUid());
return $result;
} catch (Exception $e) {
$result = array('Exception!! ' => $e->getMessage());
if (isset($e->aValidationFailures)) {
$result['ValidationFailures'] = $e->aValidationFailures;
}
return $result;
}
}
示例11: signupAction
function signupAction()
{
if ($this->request->isPost()) {
$fields = array('username', 'email', 'password', 'cpassword');
$fieldsEntered = 0;
foreach ($fields as $field) {
${$field} = $this->request->getPost($field);
if (trim(${$field}) != '') {
$fieldsEntered++;
}
}
$errors = array();
if ($fieldsEntered < count($fields)) {
array_push($errors, "Some fields were not entered.");
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
array_push($errors, "Email is invalid.");
}
if (strlen($password) < 6) {
array_push($errors, "Password must be at least 6 characters long.");
}
if ($password != $cpassword) {
array_push($errors, "Passwords don't match.");
}
$user = Users::findFirst("email = '{$email}' OR username = '{$username}'");
if ($user) {
array_push($errors, "Email or username is already taken.");
}
if (!count($errors)) {
$salt = bin2hex(openssl_random_pseudo_bytes(16, $cstrong));
$user = new Users();
$user->username = $username;
$user->email = $email;
$user->salt = $salt;
$user->password = md5($salt . $password);
if ($user->create()) {
$this->response->redirect('/login?success');
$this->view->disable();
} else {
array_push($errors, "An error occurred during the signup process.");
}
}
$this->view->errors = $errors;
}
echo $this->view->render('auth', 'signup');
}
示例12: create
public static function create($data)
{
session_start();
$headers = apache_request_headers();
$token = $headers['X-Auth-Token'];
if (!$headers['X-Auth-Token']) {
header('Invalid CSRF Token', true, 401);
return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
die;
} else {
if ($token != $_SESSION['form_token']) {
header('Invalid CSRF Token', true, 401);
return print json_encode(array('success' => false, 'status' => 400, 'msg' => 'Invalid CSRF Token / Bad Request / Unauthorized ... Please Login again'), JSON_PRETTY_PRINT);
die;
} else {
if (isset($data['username']) && empty($data['username'])) {
return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Username is required'), JSON_PRETTY_PRINT);
die;
} else {
if (isset($data['password']) && empty($data['password'])) {
return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Password is required'), JSON_PRETTY_PRINT);
die;
} else {
if (isset($data['email']) && empty($data['email'])) {
return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Email is required'), JSON_PRETTY_PRINT);
die;
} else {
if (isset($data['fname']) && empty($data['fname'])) {
return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'First Name is required'), JSON_PRETTY_PRINT);
die;
} else {
if (isset($data['lname']) && empty($data['lname'])) {
return print json_encode(array('success' => false, 'status' => 200, 'msg' => 'Last Name is required'), JSON_PRETTY_PRINT);
die;
} else {
$var = ["username" => $data['username'], "password" => $data['password'], "email" => $data['email'], "mobileno" => $data['mobileno'], "fname" => $data['fname'], "lname" => $data['lname'], "level" => $data['level']];
Users::create($var);
}
}
}
}
}
}
}
}
示例13: createPage
function createPage($smarty)
{
if (Users::loggedIn()) {
Redirect::to('?page=profile');
}
if (Input::exists()) {
if (Input::get('action') === 'register') {
$validation = new Validate();
$validation->check($_POST, array_merge(Config::get('validation/register_info'), Config::get('validation/set_password')));
if ($validation->passed()) {
try {
Users::create(array('student_id' => Input::get('sid'), 'password' => Hash::hashPassword(Input::get('password')), 'permission_group' => 1, 'name' => Input::get('name'), 'email' => Input::get('email'), 'umail' => Input::get('sid') . '@umail.leidenuniv.nl', 'phone' => Phone::formatNumber(Input::get('phone')), 'joined' => DateFormat::sql()));
Users::login(Input::get('sid'), Input::get('password'));
Notifications::addSuccess('You have been succesfully registered!');
Redirect::to('?page=profile');
} catch (Exception $e) {
Notifications::addError($e->getMessage());
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'login') {
$validation = new Validate();
$validation->check($_POST, Config::get('validation/login'));
if ($validation->passed()) {
$login = Users::login(Input::get('sid'), Input::get('password'), Input::getAsBool('remember'));
if ($login) {
Notifications::addSuccess('You have been logged in!');
Redirect::to('?page=profile');
} else {
Notifications::addValidationFail('Invalid student number or password.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
}
$smarty->assign('remember', Input::getAsBool('remember'));
$smarty->assign('name', Input::get('name'));
$smarty->assign('sid', Input::get('sid'));
$smarty->assign('email', Input::get('email'));
$smarty->assign('phone', Input::get('phone'));
return $smarty;
}
示例14: action_check
public function action_check()
{
$rules = array('email' => 'required|email|max:60', 'password' => 'required|max:60');
$validation = Validator::make(Input::get(), $rules);
if ($validation->fails()) {
return Redirect::to('signup');
}
$email = Input::get('email');
$password = Input::get('password');
$created = Users::create($email, $password);
if (Request::ajax()) {
if ($created) {
return Response::json(array('success' => true));
} else {
return Response::json(array('success' => false));
}
} else {
return Redirect::to('home');
}
}
示例15: masuk
public function masuk()
{
FacebookSession::setDefaultApplication(Config::get('facebook.appId'), Config::get('facebook.secret'));
$helper = new FacebookRedirectLoginHelper(url('/fblogin'));
$scope = array('email');
$session = $helper->getSessionFromRedirect();
if (isset($session)) {
//return Redirect::to('/bergabung');
$request = new FacebookRequest($session, 'GET', '/me');
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id');
// To Get Facebook ID
$fbfullname = $graphObject->getProperty('name');
// To Get Facebook full name
$femail = $graphObject->getProperty('email');
Session::put('logged_in', '1');
Session::put('level', 'user');
Session::put('user_name', $fbfullname);
Session::put('fbid', $fbid);
//$fbcheck = $this->checkuser($fbid,$fbfullname,$femail);
$fbcheck = $this->check($fbid);
if ($fbcheck == TRUE) {
$data = array('fbname' => $fbfullname, 'fbemail' => $femail);
Users::where('fbid', '=', $fbid)->update($data);
$userid = Users::where('fbid', '=', $fbid)->first()->id;
Session::put('user_id', $userid);
return Redirect::to('/beranda');
} else {
Users::create($data);
$userid = Users::where('fbid', '=', $fbid)->first()->id;
Session::put('user_id', $userid);
return View::make('selamat_bergabung');
}
} else {
$loginUrl = $helper->getLoginUrl($scope);
return Redirect::to($loginUrl);
}
}