MAPG-69 ability to cancel Google signup

This commit is contained in:
Bence Pőcze 2020-06-21 15:29:02 +02:00
parent 1cfbef418e
commit 6338e35cfb
3 changed files with 21 additions and 3 deletions

View File

@ -299,6 +299,14 @@ class LoginController
return new JsonContent($data);
}
public function resetGoogleSignup(): IContent
{
$this->request->session()->delete('google_user_data');
$data = ['success' => true];
return new JsonContent($data);
}
public function activate()
{
if ($this->request->user() !== null) {

View File

@ -10,14 +10,15 @@
<p class="justify">Please confirm your sign up request. Your account will be linked to your Google account.</p>
<?php endif; ?>
<input class="big fullWidth marginTop" type="email" name="email" placeholder="Email address" value="<?= $email ?>" disabled>
<div class="right marginTop">
<button type="submit">
<div class="right">
<button class="marginTop marginRight" type="submit">
<?php if ($found): ?>
Link
<?php else: ?>
Sign up
<?php endif; ?>
</button>
</button><!--
--><button id="cancelGoogleSignupButton" class="gray marginTop" type="button">Cancel</button>
</div>
</form>
</div>
@ -35,6 +36,14 @@
window.location.replace('/');
});
};
document.getElementById('cancelGoogleSignupButton').onclick = function () {
document.getElementById('loading').style.visibility = 'visible';
MapGuesser.httpRequest('POST', '/signup/google/reset', function () {
window.location.replace('/signup');
});
};
})();
</script>
<?php require ROOT . '/views/templates/main_footer.php'; ?>

View File

@ -22,6 +22,7 @@ Container::$routeCollection->post('signup-action', 'signup', [MapGuesser\Control
Container::$routeCollection->get('signup-google', 'signup/google', [MapGuesser\Controller\LoginController::class, 'getSignupWithGoogleForm']);
Container::$routeCollection->post('signup-google-action', 'signup/google', [MapGuesser\Controller\LoginController::class, 'signupWithGoogle']);
Container::$routeCollection->post('signup.reset', 'signup/reset', [MapGuesser\Controller\LoginController::class, 'resetSignup']);
Container::$routeCollection->post('signup-google.reset', 'signup/google/reset', [MapGuesser\Controller\LoginController::class, 'resetGoogleSignup']);
Container::$routeCollection->get('signup.success', 'signup/success', [MapGuesser\Controller\LoginController::class, 'getSignupSuccess']);
Container::$routeCollection->get('signup.activate', 'signup/activate/{token}', [MapGuesser\Controller\LoginController::class, 'activate']);
Container::$routeCollection->get('signup.cancel', 'signup/cancel/{token}', [MapGuesser\Controller\LoginController::class, 'cancel']);