Add active page
This commit is contained in:
parent
de087c7b4a
commit
a2fbb24615
5 changed files with 60 additions and 0 deletions
|
@ -39,3 +39,20 @@ func SendRegisterMail(user *models.User) {
|
||||||
// async send mail
|
// async send mail
|
||||||
mailer.SendAsync(msg)
|
mailer.SendAsync(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send email verify active email.
|
||||||
|
func SendActiveMail(user *models.User) {
|
||||||
|
code := CreateUserActiveCode(user, nil)
|
||||||
|
|
||||||
|
subject := "Verify your email address"
|
||||||
|
|
||||||
|
data := mailer.GetMailTmplData(user)
|
||||||
|
data["Code"] = code
|
||||||
|
body := base.RenderTemplate("mail/auth/active_email.html", data)
|
||||||
|
|
||||||
|
msg := mailer.NewMailMessage([]string{user.Email}, subject, body)
|
||||||
|
msg.Info = fmt.Sprintf("UID: %d, send email verify mail", user.Id)
|
||||||
|
|
||||||
|
// async send mail
|
||||||
|
mailer.SendAsync(msg)
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,10 @@ func SignInRequire(redirect bool) martini.Handler {
|
||||||
ctx.Render.Redirect("/")
|
ctx.Render.Redirect("/")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
} else if !ctx.User.IsActive {
|
||||||
|
ctx.Data["Title"] = "Activate Your Account"
|
||||||
|
ctx.Render.HTML(200, "user/active", ctx.Data)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,7 @@ func SignIn(ctx *middleware.Context, form auth.LogInForm) {
|
||||||
|
|
||||||
ctx.Session.Set("userId", user.Id)
|
ctx.Session.Set("userId", user.Id)
|
||||||
ctx.Session.Set("userName", user.Name)
|
ctx.Session.Set("userName", user.Name)
|
||||||
|
|
||||||
ctx.Render.Redirect("/")
|
ctx.Render.Redirect("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,3 +224,18 @@ func Pulls(ctx *middleware.Context) {
|
||||||
func Stars(ctx *middleware.Context) {
|
func Stars(ctx *middleware.Context) {
|
||||||
ctx.Render.HTML(200, "user/stars", ctx.Data)
|
ctx.Render.HTML(200, "user/stars", ctx.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Activate(ctx *middleware.Context) {
|
||||||
|
code := ctx.Query("code")
|
||||||
|
if len(code) == 0 {
|
||||||
|
ctx.Data["IsActivatePage"] = true
|
||||||
|
// Resend confirmation e-mail.
|
||||||
|
if base.Service.RegisterEmailConfirm {
|
||||||
|
auth.SendRegisterMail(ctx.User)
|
||||||
|
} else {
|
||||||
|
ctx.Data["ServiceNotEnabled"] = true
|
||||||
|
}
|
||||||
|
ctx.Render.HTML(200, "user/active", ctx.Data)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
22
templates/user/active.tmpl
Normal file
22
templates/user/active.tmpl
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{{template "base/head" .}}
|
||||||
|
{{template "base/navbar" .}}
|
||||||
|
<div id="gogs-body" class="container">
|
||||||
|
<form action="/user/activate" method="post" class="form-horizontal gogs-card" id="gogs-login-card">
|
||||||
|
<h3>Active Your Account</h3>
|
||||||
|
{{if .IsActivatePage}}
|
||||||
|
{{if .ServiceNotEnabled}}
|
||||||
|
<p>Sorry, Register Mail Confirmation has been disabled.</p>
|
||||||
|
{{else}}
|
||||||
|
<p>New confirmation e-mail has been sent to <b>{{.SignedUser.Email}}</b>, please check your inbox within 3 days.</p>
|
||||||
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
<p>Hi, {{.SignedUser.Name}}, you have an unconfirmed email address(<b>{{.SignedUser.Email}}</b>). If you haven't received a confirmation e-mail or need to resend a new one, please click botton below.</p>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-offset-4 col-md-6">
|
||||||
|
<button type="submit" class="btn btn-lg btn-primary">Click here to resend your active e-mail</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{{template "base/footer" .}}
|
1
web.go
1
web.go
|
@ -84,6 +84,7 @@ func runWeb(*cli.Context) {
|
||||||
m.Any("/user/sign_up", reqSignOut, binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)
|
m.Any("/user/sign_up", reqSignOut, binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)
|
||||||
m.Any("/user/delete", reqSignIn, user.Delete)
|
m.Any("/user/delete", reqSignIn, user.Delete)
|
||||||
m.Get("/user/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds)
|
m.Get("/user/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds)
|
||||||
|
m.Get("/user/activate", user.Activate)
|
||||||
|
|
||||||
m.Any("/user/setting", reqSignIn, binding.BindIgnErr(auth.UpdateProfileForm{}), user.Setting)
|
m.Any("/user/setting", reqSignIn, binding.BindIgnErr(auth.UpdateProfileForm{}), user.Setting)
|
||||||
m.Any("/user/setting/password", reqSignIn, binding.BindIgnErr(auth.UpdatePasswdForm{}), user.SettingPassword)
|
m.Any("/user/setting/password", reqSignIn, binding.BindIgnErr(auth.UpdatePasswdForm{}), user.SettingPassword)
|
||||||
|
|
Loading…
Add table
Reference in a new issue