123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App\Http\Controllers\Auth\Front;
- use App\Http\Controllers\Controller;
- use App\Http\Controllers\Traits\ApiResponseTrait;
- use App\Http\Requests\Front\ForgotPasswordRequest;
- use App\Models\Member;
- use App\Servers\SmsServer;
- class ForgotPasswordController extends Controller
- {
- use ApiResponseTrait;
- // 修改密码
- public function modify(ForgotPasswordRequest $request)
- {
- $phone = $request->input('phone', '');
- $password = $request->input('password', '');
- $member = Member::where('phone', $phone)->first();
- $type = $request->input('type', '');
- if( empty($member) ){
- return $this->apiResponseError(null,'账号不存在');
- }
- if( empty($type) ){
- return $this->apiResponseError(null,'接口类型必传');
- }
- // 短信验证码验证
- $sms = $request->input('sms', 'sms');
- // 短信验证码是否通过
- $result = (new SmsServer())->checkSms($sms, $phone, $type);
- if( $result['errcode'] === false ){
- return $this->apiResponseError(null,$result['errmsg']);
- }
- $member->{'password'} = bcrypt($password);
- $member->{'y_password'} = $password;
- $result = $member->save();
- if( !$result ){
- return $this->apiResponseError(null,"修改失败");
- }
- return $this->apiResponseSuccess(null, "修改成功");
- }
- }
|