本文整理汇总了PHP中common\models\User::findByMobile方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findByMobile方法的具体用法?PHP User::findByMobile怎么用?PHP User::findByMobile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\User
的用法示例。
在下文中一共展示了User::findByMobile方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUser
/**
* Finds user by [[mobile]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === null) {
$this->_user = User::findByMobile($this->mobile);
}
return $this->_user;
}
示例2: generateToken
public function generateToken()
{
$mobile = $this->_session['passwordResetMobile'];
$this->_user = User::findByMobile($mobile);
if (!User::isPasswordResetTokenValid($this->_user->password_reset_token)) {
$this->_user->generatePasswordResetToken();
}
return $this->_user->save(false);
}
示例3: actionGetcode
public function actionGetcode()
{
$request = \Yii::$app->request;
$mobile = $request->_get('mobile', NULL);
$from = $request->_get('from', '');
$type = $request->_get('type', '');
if (!EasyHelpers::checkMobile($mobile)) {
return ['code' => 2, 'msg' => '手机号码格式不正确', 'data' => []];
}
if ($from && $from == 'signup') {
$types = \Yii::$app->params['types'];
if (!in_array($type, $types)) {
return ['code' => 1, 'msg' => '用户类型不正确', 'data' => []];
}
if (in_array($type, ['master', 'user'])) {
$where = 'userMobile=\'' . $mobile . '\' AND `type`=\'' . $type . '\'';
} else {
$where = 'userMobile=\'' . $mobile . '\' AND `type`<>\'master\' AND `type`<>\'user\'';
}
$isSignup = User::find()->where($where)->One();
if ($isSignup) {
return ['code' => 1, 'msg' => '手机号码已注册', 'data' => []];
}
}
if ($from && $from == 'resetpwd') {
$user = User::findByMobile($mobile);
if (!$user) {
return ['code' => 2, 'msg' => '手机号码未注册', 'data' => []];
}
}
if ($from && $from == 'bindMobile-new') {
$newuser = User::findByMobile($mobile);
if ($newuser) {
return ['code' => 1, 'msg' => '新手机号已注册', 'data' => []];
}
}
$code = EasyHelpers::getVerifyCode($mobile);
$phone = $mobile;
if (!$phone) {
$identity = \Yii::$app->user->identity;
$phone = $identity ? $identity->userMobile : '';
}
if (!$phone) {
return ['code' => 2, 'msg' => '手机号码缺失', 'data' => []];
}
$resource = '瞄再买';
Sendmsg::widget(['callback' => [$this, 'saveMsg'], 'mobile' => $phone, 'params' => ['text' => '手机', 'code' => $code, 'resource' => $resource], 'callbackParams' => ['code' => $code, 'mobile' => $phone], 'template' => 'verifyCode']);
$resMsg = $this->resMessage;
if ($resMsg) {
if (!isset($resMsg[0])) {
$resMsg[0] = $resMsg['returnMsg'];
}
return ['code' => 2, 'msg' => $resMsg[0], 'data' => []];
}
return ['code' => 0, 'msg' => '验证码发送成功'];
}
示例4: resetPassword
/**
* Resets password.
*
* @return boolean if password was reset.
*/
public function resetPassword()
{
$user = User::findByMobile($this->userMobile);
$user->setPassword($this->password);
$res = $user->save();
if ($res !== false) {
return true;
} else {
$this->addError('save', '更改失败');
return false;
}
}
示例5: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === false) {
$userName = $this->username;
if (EasyHelpers::checkEmail($userName)) {
// do username;
$this->_user = User::findByEmail($userName);
} elseif (EasyHelpers::checkMobile($userName)) {
// do mobile;
$this->_user = User::findByMobile($userName);
} else {
return false;
}
}
return $this->_user;
}
示例6: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
protected function getUser()
{
if ($this->_user === null) {
$this->_user = User::findByUsername($this->username);
}
if ($this->_user === null) {
$this->_user = User::findByEmail($this->username);
}
if ($this->_user === null) {
$this->_user = User::findByMobile($this->username);
}
if ($this->_user && !in_array($this->_user->group, [User::GROUP_ADMIN, User::GROUP_WRITER])) {
return false;
}
return $this->_user;
}
示例7: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
protected function getUser()
{
if ($this->_user === null) {
$this->_user = User::findByUsername($this->username);
}
if ($this->_user === null) {
$this->_user = User::findByEmail($this->username);
}
if ($this->_user === null) {
$this->_user = User::findByMobile($this->username);
}
return $this->_user;
}
示例8: actionGetstoreinfo
/**
* 根据手机号获取店铺信息
* @return type
*/
public function actionGetstoreinfo()
{
$request = \Yii::$app->request;
$userMobile = $request->_get('userMobile', 0);
$userId = $request->_get('userId', 0);
$usign = $request->_get('usign', '');
if ($usign != EasyHelpers::encrypty($userId, \Yii::$app->params['key'])) {
return ['code' => 5, 'msg' => '非法数据'];
}
if (!$userMobile) {
return ['code' => 1, 'msg' => '非法数据'];
}
if (!EasyHelpers::checkMobile($userMobile)) {
return ['code' => 1, 'msg' => '手机号格式不正确'];
}
$user = User::findByMobile($userMobile);
if (!$user) {
return ['code' => 1, 'msg' => '用户不存在'];
} else {
if ($user->userId == $userId) {
return ['code' => 1, 'msg' => '不能给自己发送'];
}
$store = Store::getStoreInfo($user->userId);
if (!$store) {
return ['code' => 1, 'msg' => '用户没有店铺'];
}
if ($store['status'] != 'approval') {
return ['code' => 1, 'msg' => '用户店铺没有通过审核'];
}
}
$data['userId'] = $store['userId'];
$data['storeName'] = $store['storeName'];
$data['logo'] = EasyHelpers::getStoreLogoUrl($store['logo']);
return ['code' => 0, 'msg' => '操作成功', 'data' => $data];
}
示例9: actionBindmobile
/**
* bind mobile api
* @return type
*/
public function actionBindmobile()
{
$request = \Yii::$app->request;
$data['oldmobile'] = $request->_get('oldmobile', '');
$data['oldcode'] = $request->_get('oldcode', '');
$data['newmobile'] = $request->_get('newmobile', '');
$data['newcode'] = $request->_get('newcode', '');
$data['userId'] = $request->_get('userId', '');
$data['usign'] = $request->_get('usign', '');
if ($data['usign'] != EasyHelpers::encrypty($data['userId'], \Yii::$app->params['key'])) {
return ['code' => 5, 'msg' => '非法数据'];
}
$Iduser = \common\models\User::findOne(['userId' => $data['userId']]);
if ($Iduser && $data['oldmobile'] != $Iduser['userMobile']) {
return ['code' => 6, 'msg' => '非法数据'];
}
$oldcode = EasyHelpers::getVerifyCode($data['oldmobile']);
$newcode = EasyHelpers::getVerifyCode($data['newmobile']);
if ($data['oldcode'] != $oldcode) {
return ['code' => 1, 'msg' => '已绑定手机号验证码不正确'];
}
if ($data['newcode'] != $newcode) {
return ['code' => 1, 'msg' => '新手机号验证码不正确'];
}
$user = \common\models\User::findByMobile($data['oldmobile']);
$newuser = \common\models\User::findByMobile($data['newmobile']);
if ($newuser) {
['code' => 1, 'msg' => '新手机号已经注册'];
}
if ($user) {
$user->userMobile = $data['newmobile'];
if ($user->save()) {
return ['code' => 0, 'msg' => '手机绑定成功,请重新登录'];
}
}
return ['code' => 1, 'msg' => '用户信息拉取失败'];
}