@@ -145,4 +196,9 @@ const checkout = () => {
.mollie_checkout > input[type="number"] {
flex: 1 1 auto;
}
+
+.bankicon {
+ width: 40px;
+ height: 30px;
+}
diff --git a/svelte/src/user_home/Subscription.svelte b/svelte/src/user_home/Subscription.svelte
index 3c6ac98..e4267e9 100644
--- a/svelte/src/user_home/Subscription.svelte
+++ b/svelte/src/user_home/Subscription.svelte
@@ -50,8 +50,17 @@ onMount(() => {
Payment successful!
- The credit has been added to your account balance. Activate a
- subscription plan below to finish upgrading your account.
+ Thank you for supporting pixeldrain! The credit has been added
+ to your account balance. Activate a subscription plan below to
+ finish upgrading your account.
+
+
+ If your account credit has not been updated, please check the
+ status of your invoice on the invoices page.
+ Depending on the payment processor you used to can take a while
+ before your credit is deposited. If it takes too long contact
+ support@pixeldrain.com.
{/if}
diff --git a/webcontroller/user_account.go b/webcontroller/user_account.go
index a89d5dd..3baebee 100644
--- a/webcontroller/user_account.go
+++ b/webcontroller/user_account.go
@@ -24,9 +24,9 @@ func formAPIError(err error, f *Form) {
return name
}
- if err, ok := err.(pixelapi.Error); ok {
- if err.StatusCode == "multiple_errors" {
- for _, err := range err.Errors {
+ if apierr, ok := err.(pixelapi.Error); ok {
+ if apierr.StatusCode == "multiple_errors" {
+ for _, err := range apierr.Errors {
// Modify the message to make it more user-friendly
if err.StatusCode == "string_out_of_range" {
err.Message = fmt.Sprintf(
@@ -47,7 +47,7 @@ func formAPIError(err error, f *Form) {
f.SubmitMessages = append(f.SubmitMessages, template.HTML(err.Message))
}
} else {
- f.SubmitMessages = append(f.SubmitMessages, template.HTML(err.Message))
+ f.SubmitMessages = append(f.SubmitMessages, template.HTML(apierr.Message))
}
} else {
log.Error("Error submitting form: %s", err)
@@ -141,6 +141,7 @@ func (wc *WebController) registerForm(td *TemplateData, r *http.Request) (f Form
}
log.Debug("capt: %s", f.FieldVal("recaptcha_response"))
+ // Register the user
if err = td.PixelAPI.UserRegister(
f.FieldVal("username"),
f.FieldVal("email"),
@@ -148,14 +149,31 @@ func (wc *WebController) registerForm(td *TemplateData, r *http.Request) (f Form
f.FieldVal("recaptcha_response"),
); err != nil {
formAPIError(err, &f)
- } else {
- // Request was a success
- f.SubmitSuccess = true
- f.SubmitMessages = []template.HTML{
- `Registration completed! You can now
log in ` +
- `to your account.
We're glad to have you on ` +
- `board, have fun sharing!`}
+ return f
}
+
+ // Registration successful. Log the user in
+ session, err := td.PixelAPI.PostUserLogin(
+ f.FieldVal("username"),
+ f.FieldVal("password"),
+ "website login",
+ )
+ if err != nil {
+ log.Debug("Login failed: %s", err)
+ formAPIError(err, &f)
+ return
+ }
+
+ f.Extra.SetCookie = wc.sessionCookie(session)
+ f.Extra.RedirectTo = wc.loginRedirect(r)
+
+ // Request was a success
+ f.SubmitSuccess = true
+ f.SubmitMessages = []template.HTML{
+ `Registration completed! You can now
log in ` +
+ `to your account.
We're glad to have you on ` +
+ `board, have fun sharing!`}
+
}
return f
}
@@ -186,6 +204,13 @@ func (wc *WebController) loginForm(td *TemplateData, r *http.Request) (f Form) {
),
}
+ // If the user is already logged in we redirect to the target page
+ // immediately
+ if td.Authenticated {
+ f.Extra.RedirectTo = wc.loginRedirect(r)
+ return f
+ }
+
if f.ReadInput(r) {
if session, err := td.PixelAPI.PostUserLogin(
f.FieldVal("username"),
@@ -200,29 +225,41 @@ func (wc *WebController) loginForm(td *TemplateData, r *http.Request) (f Form) {
f.SubmitMessages = []template.HTML{"Success!"}
// Set the autentication cookie
- f.Extra.SetCookie = &http.Cookie{
- Name: "pd_auth_key",
- Value: session.AuthKey.String(),
- Path: "/",
- Expires: time.Now().AddDate(50, 0, 0),
- Domain: wc.config.SessionCookieDomain,
-
- // Strict means the Cookie will only be sent when the user
- // reaches a page by a link from the same domain. Lax means any
- // page on the domain gets the cookie and None means embedded
- // content also gets the cookie.
- //
- // Users who see pixeldrain links in iframes also expect their
- // accounts to be logged in so we need to use None
- SameSite: http.SameSiteNoneMode,
- Secure: true,
- }
- f.Extra.RedirectTo = "/user"
+ f.Extra.SetCookie = wc.sessionCookie(session)
+ f.Extra.RedirectTo = wc.loginRedirect(r)
}
}
return f
}
+func (wc *WebController) sessionCookie(session pixelapi.UserSession) *http.Cookie {
+ return &http.Cookie{
+ Name: "pd_auth_key",
+ Value: session.AuthKey.String(),
+ Path: "/",
+ Expires: time.Now().AddDate(50, 0, 0),
+ Domain: wc.config.SessionCookieDomain,
+
+ // Strict means the Cookie will only be sent when the user
+ // reaches a page by a link from the same domain. Lax means any
+ // page on the domain gets the cookie and None means embedded
+ // content also gets the cookie.
+ //
+ // Users who see pixeldrain links in iframes also expect their
+ // accounts to be logged in so we need to use None
+ SameSite: http.SameSiteNoneMode,
+ Secure: true,
+ }
+}
+
+func (wc *WebController) loginRedirect(r *http.Request) string {
+ if redirect := r.URL.Query().Get("redirect"); redirect == "checkout" {
+ return "/user/prepaid/deposit#deposit"
+ } else {
+ return "/user"
+ }
+}
+
func (wc *WebController) passwordResetForm(td *TemplateData, r *http.Request) (f Form) {
f = Form{
Name: "password_reset",