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$")
|
||||
|
||||
func BuildRegister() string {
|
||||
func BuildRegister(destination string) string {
|
||||
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$")
|
||||
|
@ -341,7 +345,7 @@ func BuildProjectNew() string {
|
|||
func BuildProjectNewJam() string {
|
||||
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-]+))?")
|
||||
|
|
|
@ -33,11 +33,13 @@ func LoginPage(c *RequestContext) ResponseData {
|
|||
return c.RejectRequest("You are already logged in.")
|
||||
}
|
||||
|
||||
redirect := c.Req.URL.Query().Get("redirect")
|
||||
|
||||
var res ResponseData
|
||||
res.MustWriteTemplate("auth_login.html", LoginPageData{
|
||||
BaseData: getBaseData(c, "Log in", nil),
|
||||
RedirectUrl: c.Req.URL.Query().Get("redirect"),
|
||||
RegisterUrl: hmnurl.BuildRegister(),
|
||||
RedirectUrl: redirect,
|
||||
RegisterUrl: hmnurl.BuildRegister(redirect),
|
||||
ForgotPasswordUrl: hmnurl.BuildRequestPasswordReset(),
|
||||
}, c.Perf)
|
||||
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.
|
||||
baseData.AddImmediateNotice("failure", "Incorrect password. Please try again.")
|
||||
res.MustWriteTemplate("auth_email_validation.html", EmailValidationData{
|
||||
BaseData: baseData,
|
||||
Token: token,
|
||||
Username: username,
|
||||
BaseData: baseData,
|
||||
Token: token,
|
||||
Username: username,
|
||||
DestinationURL: destination,
|
||||
}, c.Perf)
|
||||
return res
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ func getBaseData(c *RequestContext, title string, breadcrumbs []templates.Breadc
|
|||
LoginActionUrl: hmnurl.BuildLoginAction(c.FullUrl()),
|
||||
LogoutActionUrl: hmnurl.BuildLogoutAction(c.FullUrl()),
|
||||
ForgotPasswordUrl: hmnurl.BuildRequestPasswordReset(),
|
||||
RegisterUrl: hmnurl.BuildRegister(),
|
||||
RegisterUrl: hmnurl.BuildRegister(""),
|
||||
|
||||
HMNHomepageUrl: hmnurl.BuildHomepage(),
|
||||
ProjectIndexUrl: hmnurl.BuildProjectIndex(1),
|
||||
|
@ -75,7 +75,7 @@ func getBaseData(c *RequestContext, title string, breadcrumbs []templates.Breadc
|
|||
FishbowlUrl: hmnurl.BuildFishbowlIndex(),
|
||||
ForumsUrl: hmnurl.HMNProjectContext.BuildForum(nil, 1),
|
||||
LibraryUrl: hmnurl.BuildLibrary(),
|
||||
ConferencesUrl: hmnurl.BuildConferences(),
|
||||
ConferencesUrl: hmnurl.BuildConferences(),
|
||||
},
|
||||
Footer: templates.Footer{
|
||||
HomepageUrl: hmnurl.BuildHomepage(),
|
||||
|
|
Loading…
Reference in New Issue