Use the register destination when coming from the login page
This commit is contained in:
parent
782db18cc3
commit
d7b43fdea0
|
@ -105,9 +105,13 @@ func BuildLogoutAction(redir string) string {
|
||||||
|
|
||||||
var RegexRegister = regexp.MustCompile("^/register$")
|
var RegexRegister = regexp.MustCompile("^/register$")
|
||||||
|
|
||||||
func BuildRegister() string {
|
func BuildRegister(destination string) string {
|
||||||
defer CatchPanic()
|
defer CatchPanic()
|
||||||
return Url("/register", nil)
|
var query []Q
|
||||||
|
if destination != "" {
|
||||||
|
query = append(query, Q{"destination", destination})
|
||||||
|
}
|
||||||
|
return Url("/register", query)
|
||||||
}
|
}
|
||||||
|
|
||||||
var RegexRegistrationSuccess = regexp.MustCompile("^/registered_successfully$")
|
var RegexRegistrationSuccess = regexp.MustCompile("^/registered_successfully$")
|
||||||
|
@ -341,7 +345,7 @@ func BuildProjectNew() string {
|
||||||
func BuildProjectNewJam() string {
|
func BuildProjectNewJam() string {
|
||||||
defer CatchPanic()
|
defer CatchPanic()
|
||||||
|
|
||||||
return Url("/p/new", []Q{Q{Name: "jam", Value: "1"}})
|
return Url("/p/new", []Q{{Name: "jam", Value: "1"}})
|
||||||
}
|
}
|
||||||
|
|
||||||
var RegexPersonalProject = regexp.MustCompile("^/p/(?P<projectid>[0-9]+)(/(?P<projectslug>[a-zA-Z0-9-]+))?")
|
var RegexPersonalProject = regexp.MustCompile("^/p/(?P<projectid>[0-9]+)(/(?P<projectslug>[a-zA-Z0-9-]+))?")
|
||||||
|
|
|
@ -33,11 +33,13 @@ func LoginPage(c *RequestContext) ResponseData {
|
||||||
return c.RejectRequest("You are already logged in.")
|
return c.RejectRequest("You are already logged in.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redirect := c.Req.URL.Query().Get("redirect")
|
||||||
|
|
||||||
var res ResponseData
|
var res ResponseData
|
||||||
res.MustWriteTemplate("auth_login.html", LoginPageData{
|
res.MustWriteTemplate("auth_login.html", LoginPageData{
|
||||||
BaseData: getBaseData(c, "Log in", nil),
|
BaseData: getBaseData(c, "Log in", nil),
|
||||||
RedirectUrl: c.Req.URL.Query().Get("redirect"),
|
RedirectUrl: redirect,
|
||||||
RegisterUrl: hmnurl.BuildRegister(),
|
RegisterUrl: hmnurl.BuildRegister(redirect),
|
||||||
ForgotPasswordUrl: hmnurl.BuildRequestPasswordReset(),
|
ForgotPasswordUrl: hmnurl.BuildRequestPasswordReset(),
|
||||||
}, c.Perf)
|
}, c.Perf)
|
||||||
return res
|
return res
|
||||||
|
@ -384,9 +386,10 @@ func EmailConfirmationSubmit(c *RequestContext) ResponseData {
|
||||||
// NOTE(asaf): We can report that the password is incorrect, because an attacker wouldn't have a valid token to begin with.
|
// NOTE(asaf): We can report that the password is incorrect, because an attacker wouldn't have a valid token to begin with.
|
||||||
baseData.AddImmediateNotice("failure", "Incorrect password. Please try again.")
|
baseData.AddImmediateNotice("failure", "Incorrect password. Please try again.")
|
||||||
res.MustWriteTemplate("auth_email_validation.html", EmailValidationData{
|
res.MustWriteTemplate("auth_email_validation.html", EmailValidationData{
|
||||||
BaseData: baseData,
|
BaseData: baseData,
|
||||||
Token: token,
|
Token: token,
|
||||||
Username: username,
|
Username: username,
|
||||||
|
DestinationURL: destination,
|
||||||
}, c.Perf)
|
}, c.Perf)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ func getBaseData(c *RequestContext, title string, breadcrumbs []templates.Breadc
|
||||||
LoginActionUrl: hmnurl.BuildLoginAction(c.FullUrl()),
|
LoginActionUrl: hmnurl.BuildLoginAction(c.FullUrl()),
|
||||||
LogoutActionUrl: hmnurl.BuildLogoutAction(c.FullUrl()),
|
LogoutActionUrl: hmnurl.BuildLogoutAction(c.FullUrl()),
|
||||||
ForgotPasswordUrl: hmnurl.BuildRequestPasswordReset(),
|
ForgotPasswordUrl: hmnurl.BuildRequestPasswordReset(),
|
||||||
RegisterUrl: hmnurl.BuildRegister(),
|
RegisterUrl: hmnurl.BuildRegister(""),
|
||||||
|
|
||||||
HMNHomepageUrl: hmnurl.BuildHomepage(),
|
HMNHomepageUrl: hmnurl.BuildHomepage(),
|
||||||
ProjectIndexUrl: hmnurl.BuildProjectIndex(1),
|
ProjectIndexUrl: hmnurl.BuildProjectIndex(1),
|
||||||
|
@ -75,7 +75,7 @@ func getBaseData(c *RequestContext, title string, breadcrumbs []templates.Breadc
|
||||||
FishbowlUrl: hmnurl.BuildFishbowlIndex(),
|
FishbowlUrl: hmnurl.BuildFishbowlIndex(),
|
||||||
ForumsUrl: hmnurl.HMNProjectContext.BuildForum(nil, 1),
|
ForumsUrl: hmnurl.HMNProjectContext.BuildForum(nil, 1),
|
||||||
LibraryUrl: hmnurl.BuildLibrary(),
|
LibraryUrl: hmnurl.BuildLibrary(),
|
||||||
ConferencesUrl: hmnurl.BuildConferences(),
|
ConferencesUrl: hmnurl.BuildConferences(),
|
||||||
},
|
},
|
||||||
Footer: templates.Footer{
|
Footer: templates.Footer{
|
||||||
HomepageUrl: hmnurl.BuildHomepage(),
|
HomepageUrl: hmnurl.BuildHomepage(),
|
||||||
|
|
Loading…
Reference in New Issue