func DeleteAuthSource(ctx *middleware.Context, params martini.Params) { ctx.Data["Title"] = "Delete Authentication" ctx.Data["PageIsAuths"] = true id, err := base.StrTo(params["authid"]).Int64() if err != nil { ctx.Handle(404, "admin.auths.DeleteAuth", err) return } a, err := models.GetLoginSourceById(id) if err != nil { ctx.Handle(500, "admin.auths.DeleteAuth", err) return } if err = models.DelLoginSource(a); err != nil { switch err { case models.ErrAuthenticationUserUsed: ctx.Flash.Error("This authentication still has used by some users, you should move them and then delete again.") ctx.Redirect("/admin/auths/" + params["authid"]) default: ctx.Handle(500, "admin.auths.DeleteAuth", err) } return } log.Trace("%s Authentication deleted by admin(%s): %s", ctx.Req.RequestURI, ctx.User.LowerName, ctx.User.LowerName) ctx.Redirect("/admin/auths") }
func DeleteAuthSource(ctx *middleware.Context) { id := com.StrTo(ctx.Params(":authid")).MustInt64() if id == 0 { ctx.Handle(404, "DeleteAuthSource", nil) return } a, err := models.GetLoginSourceById(id) if err != nil { ctx.Handle(500, "GetLoginSourceById", err) return } if err = models.DelLoginSource(a); err != nil { switch err { case models.ErrAuthenticationUserUsed: ctx.Flash.Error("form.still_own_user") ctx.Redirect(setting.AppSubUrl + "/admin/auths/" + ctx.Params(":authid")) default: ctx.Handle(500, "DelLoginSource", err) } return } log.Trace("Authentication deleted by admin(%s): %s", ctx.User.Name, a.Name) ctx.Redirect(setting.AppSubUrl + "/admin/auths") }