Checking authentication on the backend
This commit is contained in:
@ -297,3 +297,7 @@ func (app *application) CreateAuthToken(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
_ = app.writeJSON(w, http.StatusOK, payload)
|
||||
}
|
||||
|
||||
func (app *application) CheckAuthentication(w http.ResponseWriter, r *http.Request) {
|
||||
app.invalidCredentials(w)
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ func (app *application) routes() http.Handler {
|
||||
mux.Post("/api/create-customer-and-subscribe-to-plan", app.CreateCustomerAndSubscribeToPlan)
|
||||
|
||||
mux.Post("/api/authenticate", app.CreateAuthToken)
|
||||
mux.Post("/api/is-authenticated", app.CheckAuthentication)
|
||||
|
||||
return mux
|
||||
}
|
||||
|
@ -76,8 +76,10 @@ Virtual Terminal
|
||||
{{ define "js" }}
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
<script type="module">
|
||||
import {stripeInit} from "/static/js/common.js";
|
||||
import {stripeInit, checkAuth} from "/static/js/common.js";
|
||||
import {val} from "/static/js/stripe.js"
|
||||
|
||||
checkAuth({{.API}});
|
||||
stripeInit('{{.StripePubKey}}');
|
||||
document.getElementById("charge_amount").addEventListener("change", (evt) => {
|
||||
if (evt.target.value !== "") {
|
||||
|
Reference in New Issue
Block a user