Created
October 10, 2017 19:02
-
-
Save deleugpn/847617e702f8adeb7597e0c9680b6d2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @param Request $request | |
| * @return \Illuminate\Http\RedirectResponse | |
| */ | |
| public function update(Request $request) | |
| { | |
| if (is_null($request->get('token'))) { | |
| return $this->disableToken(); | |
| } | |
| $secretKey = $request->get('secret'); | |
| $token = $request->get('token'); | |
| if (Google2FA::verifyKey($secretKey, $token)) { | |
| auth()->user()->update(['google_token' => $secretKey]); | |
| return redirect('/profile/token')->with('success', 'Google Token successfully enabled!'); | |
| } | |
| return redirect('/profile/token')->withErrors(['error' => 'The provided token does not match.']); | |
| } | |
| /** | |
| * @return \Illuminate\Http\RedirectResponse | |
| */ | |
| private function disableToken() | |
| { | |
| auth()->user()->update(['google_token' => null]); | |
| return redirect('/profile/token')->with('success', 'Google Token successfully removed!'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment