123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace Themes\kbgolf\pro\app\Http\Controllers\Auth;
- use App\Http\Controllers\Controller;
- use App\Services\CallApiService;
- use Illuminate\Support\Facades\Validator;
- class PasswordChangeController extends Controller
- {
- private $callApiService;
- public function __construct(CallApiService $callApiService)
- {
- $this->callApiService = $callApiService;
- }
- public function index()
- {
- // $response = $this->callApiService->callApi([
- // 'url' => 'member-passwd-reset',
- // 'data' => [
- // 'ResetCode' => request('code')
- // ]
- // ]);
- //
- //// dd($response);
- // if (empty(request('code')) || $this->callApiService->verifyApiError($response)) {
- // return redirect()->route('password-reset-code-failed');
- // }
- //
- // $passwdPolicy = setupPasswdPolicy('member');
- //
- // return view('views.auth.password-change', [
- // 'policyDesc' => $passwdPolicy['PolicyDesc']
- // ]);
- return view('views.auth.password-change', [
- 'policyDesc' => ''
- ]);
- }
- public function store()
- {
- $passwdPolicy = setupPasswdPolicy('member');
- if ($this->callApiService->verifyApiError($passwdPolicy)) {
- notify()->error($passwdPolicy['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- $passwdRules = makePasswdRules($passwdPolicy);
- $validator = validator::make(request()->all(), [
- 'password' => $passwdRules
- ]);
- if ($validator->fails()) {
- return redirect()->back()->withErrors($validator)->withInput();
- }
- $response = $this->callApiService->callApi([
- 'url' => 'member-passwd-reset',
- 'data' => [
- 'ResetCode' => request('code'),
- 'Passwd' => request('password')
- ]
- ]);
- // dd($response);
- if ($this->callApiService->verifyApiError($response)) {
- notify()->error($response['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- // notify()->success(_e('Action completed'), 'Success', 'bottomRight');
- return redirect()->route('member-login');
- }
- }
|