func ToCommit(c *git.Commit) *api.PayloadCommit { authorUsername := "" author, err := models.GetUserByEmail(c.Author.Email) if err == nil { authorUsername = author.Name } committerUsername := "" committer, err := models.GetUserByEmail(c.Committer.Email) if err == nil { committerUsername = committer.Name } return &api.PayloadCommit{ ID: c.ID.String(), Message: c.Message(), URL: "Not implemented", Author: &api.PayloadUser{ Name: c.Author.Name, Email: c.Author.Email, UserName: authorUsername, }, Committer: &api.PayloadUser{ Name: c.Committer.Name, Email: c.Committer.Email, UserName: committerUsername, }, Timestamp: c.Author.When, } }
func Email2User(ctx *middleware.Context) { u, err := models.GetUserByEmail(ctx.Query("email")) if err != nil { if models.IsErrUserNotExist(err) { ctx.Handle(404, "GetUserByEmail", err) } else { ctx.Handle(500, "GetUserByEmail", err) } return } ctx.Redirect(setting.AppSubUrl + "/user/" + u.Name) }
func Email2User(ctx *middleware.Context) { u, err := models.GetUserByEmail(ctx.Query("email")) if err != nil { if err == models.ErrUserNotExist { ctx.Handle(404, "user.Email2User(GetUserByEmail)", err) } else { ctx.Handle(500, "user.Email2User(GetUserByEmail)", err) } return } ctx.Redirect("/user/" + u.Name) }
func ForgotPasswdPost(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("auth.forgot_password") if setting.MailService == nil { ctx.Handle(403, "ForgotPasswdPost", nil) return } ctx.Data["IsResetRequest"] = true email := ctx.Query("email") ctx.Data["Email"] = email u, err := models.GetUserByEmail(email) if err != nil { if models.IsErrUserNotExist(err) { ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 ctx.Data["IsResetSent"] = true ctx.HTML(200, FORGOT_PASSWORD) return } else { ctx.Handle(500, "user.ResetPasswd(check existence)", err) } return } if !u.IsLocal() { ctx.Data["Err_Email"] = true ctx.RenderWithErr(ctx.Tr("auth.non_local_account"), FORGOT_PASSWORD, nil) return } if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) { ctx.Data["ResendLimited"] = true ctx.HTML(200, FORGOT_PASSWORD) return } models.SendResetPasswordMail(ctx.Context, u) if err = ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil { log.Error(4, "Set cache(MailResendLimit) fail: %v", err) } ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 ctx.Data["IsResetSent"] = true ctx.HTML(200, FORGOT_PASSWORD) }
func ForgotPasswdPost(ctx *middleware.Context) { ctx.Data["Title"] = "Forgot Password" if base.MailService == nil { ctx.Handle(403, "user.ForgotPasswdPost", nil) return } ctx.Data["IsResetRequest"] = true email := ctx.Query("email") u, err := models.GetUserByEmail(email) if err != nil { if err == models.ErrUserNotExist { ctx.RenderWithErr("This e-mail address does not associate to any account.", "user/forgot_passwd", nil) } else { ctx.Handle(500, "user.ResetPasswd(check existence)", err) } return } if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) { ctx.Data["ResendLimited"] = true ctx.HTML(200, "user/forgot_passwd") return } mailer.SendResetPasswdMail(ctx.Render, u) if err = ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil { log.Error("Set cache(MailResendLimit) fail: %v", err) } ctx.Data["Email"] = email ctx.Data["Hours"] = base.Service.ActiveCodeLives / 60 ctx.Data["IsResetSent"] = true ctx.HTML(200, "user/forgot_passwd") }