Explorar el Código

Fix type in unused constant name (#111)

* Write LDAP, SMTP, PAM, DLDAP back to all uppercase

* Fix type in unused constant name

* Other MixCased fixes

* Complete MixerCasing of template constants

* Re uppercase LTS and LDAPS suffixes

* Uppercase JSON suffix in constant names

* Proper case LoginNoType

* Prefix unexported template path constants with "tpl"
tags/v1.0.0
Sandro Santilli hace 7 años
padre
commit
864d1b1f9f

+ 1
- 1
models/issue_comment.go Ver fichero

// Reference from a commit (not part of a pull request) // Reference from a commit (not part of a pull request)
CommentTypeCommitRef CommentTypeCommitRef
// Reference from a comment // Reference from a comment
CommentTypeComment_REF
CommentTypeCommentRef
// Reference from a pull request // Reference from a pull request
CommentTypePullRef CommentTypePullRef
) )

+ 34
- 34
models/login_source.go Ver fichero



// Note: new type must append to the end of list to maintain compatibility. // Note: new type must append to the end of list to maintain compatibility.
const ( const (
LoginNotype LoginType = iota
LoginNoType LoginType = iota
LoginPlain // 1 LoginPlain // 1
LoginLdap // 2
LoginSmtp // 3
LoginPam // 4
LoginDldap // 5
LoginLDAP // 2
LoginSMTP // 3
LoginPAM // 4
LoginDLDAP // 5
) )


var LoginNames = map[LoginType]string{ var LoginNames = map[LoginType]string{
LoginLdap: "LDAP (via BindDN)",
LoginDldap: "LDAP (simple auth)", // Via direct bind
LoginSmtp: "SMTP",
LoginPam: "PAM",
LoginLDAP: "LDAP (via BindDN)",
LoginDLDAP: "LDAP (simple auth)", // Via direct bind
LoginSMTP: "SMTP",
LoginPAM: "PAM",
} }


var SecurityProtocolNames = map[ldap.SecurityProtocol]string{ var SecurityProtocolNames = map[ldap.SecurityProtocol]string{
ldap.SecurityProtocolUnencrypted: "Unencrypted", ldap.SecurityProtocolUnencrypted: "Unencrypted",
ldap.SecurityProtocolLdaps: "LDAPS",
ldap.SecurityProtocolStartTls: "StartTLS",
ldap.SecurityProtocolLDAPS: "LDAPS",
ldap.SecurityProtocolStartTLS: "StartTLS",
} }


// Ensure structs implemented interface. // Ensure structs implemented interface.
switch colName { switch colName {
case "type": case "type":
switch LoginType(Cell2Int64(val)) { switch LoginType(Cell2Int64(val)) {
case LoginLdap, LoginDldap:
case LoginLDAP, LoginDLDAP:
source.Cfg = new(LDAPConfig) source.Cfg = new(LDAPConfig)
case LoginSmtp:
case LoginSMTP:
source.Cfg = new(SMTPConfig) source.Cfg = new(SMTPConfig)
case LoginPam:
case LoginPAM:
source.Cfg = new(PAMConfig) source.Cfg = new(PAMConfig)
default: default:
panic("unrecognized login source type: " + com.ToStr(*val)) panic("unrecognized login source type: " + com.ToStr(*val))
} }


func (source *LoginSource) IsLDAP() bool { func (source *LoginSource) IsLDAP() bool {
return source.Type == LoginLdap
return source.Type == LoginLDAP
} }


func (source *LoginSource) IsDLDAP() bool { func (source *LoginSource) IsDLDAP() bool {
return source.Type == LoginDldap
return source.Type == LoginDLDAP
} }


func (source *LoginSource) IsSMTP() bool { func (source *LoginSource) IsSMTP() bool {
return source.Type == LoginSmtp
return source.Type == LoginSMTP
} }


func (source *LoginSource) IsPAM() bool { func (source *LoginSource) IsPAM() bool {
return source.Type == LoginPam
return source.Type == LoginPAM
} }


func (source *LoginSource) HasTLS() bool { func (source *LoginSource) HasTLS() bool {


func (source *LoginSource) UseTLS() bool { func (source *LoginSource) UseTLS() bool {
switch source.Type { switch source.Type {
case LoginLdap, LoginDldap:
case LoginLDAP, LoginDLDAP:
return source.LDAP().SecurityProtocol != ldap.SecurityProtocolUnencrypted return source.LDAP().SecurityProtocol != ldap.SecurityProtocolUnencrypted
case LoginSmtp:
case LoginSMTP:
return source.SMTP().TLS return source.SMTP().TLS
} }




func (source *LoginSource) SkipVerify() bool { func (source *LoginSource) SkipVerify() bool {
switch source.Type { switch source.Type {
case LoginLdap, LoginDldap:
case LoginLDAP, LoginDLDAP:
return source.LDAP().SkipVerify return source.LDAP().SkipVerify
case LoginSmtp:
case LoginSMTP:
return source.SMTP().SkipVerify return source.SMTP().SkipVerify
} }


// LoginViaLDAP queries if login/password is valid against the LDAP directory pool, // LoginViaLDAP queries if login/password is valid against the LDAP directory pool,
// and create a local user if success when enabled. // and create a local user if success when enabled.
func LoginViaLDAP(user *User, login, passowrd string, source *LoginSource, autoRegister bool) (*User, error) { func LoginViaLDAP(user *User, login, passowrd string, source *LoginSource, autoRegister bool) (*User, error) {
username, fn, sn, mail, isAdmin, succeed := source.Cfg.(*LDAPConfig).SearchEntry(login, passowrd, source.Type == LoginDldap)
username, fn, sn, mail, isAdmin, succeed := source.Cfg.(*LDAPConfig).SearchEntry(login, passowrd, source.Type == LoginDLDAP)
if !succeed { if !succeed {
// User not in LDAP, do nothing // User not in LDAP, do nothing
return nil, ErrUserNotExist{0, login} return nil, ErrUserNotExist{0, login}
} }


const ( const (
SmtpPlain = "PLAIN"
SmtpLogin = "LOGIN"
SMTPPlain = "PLAIN"
SMTPLogin = "LOGIN"
) )


var SMTPAuths = []string{SmtpPlain, SmtpLogin}
var SMTPAuths = []string{SMTPPlain, SMTPLogin}


func SMTPAuth(a smtp.Auth, cfg *SMTPConfig) error { func SMTPAuth(a smtp.Auth, cfg *SMTPConfig) error {
c, err := smtp.Dial(fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)) c, err := smtp.Dial(fmt.Sprintf("%s:%d", cfg.Host, cfg.Port))
} }


var auth smtp.Auth var auth smtp.Auth
if cfg.Auth == SmtpPlain {
if cfg.Auth == SMTPPlain {
auth = smtp.PlainAuth("", login, password, cfg.Host) auth = smtp.PlainAuth("", login, password, cfg.Host)
} else if cfg.Auth == SmtpLogin {
} else if cfg.Auth == SMTPLogin {
auth = &smtpLoginAuth{login, password} auth = &smtpLoginAuth{login, password}
} else { } else {
return nil, errors.New("Unsupported SMTP auth type") return nil, errors.New("Unsupported SMTP auth type")
Name: strings.ToLower(username), Name: strings.ToLower(username),
Email: login, Email: login,
Passwd: password, Passwd: password,
LoginType: LoginSmtp,
LoginType: LoginSMTP,
LoginSource: sourceID, LoginSource: sourceID,
LoginName: login, LoginName: login,
IsActive: true, IsActive: true,
Name: login, Name: login,
Email: login, Email: login,
Passwd: password, Passwd: password,
LoginType: LoginPam,
LoginType: LoginPAM,
LoginSource: sourceID, LoginSource: sourceID,
LoginName: login, LoginName: login,
IsActive: true, IsActive: true,
} }


switch source.Type { switch source.Type {
case LoginLdap, LoginDldap:
case LoginLDAP, LoginDLDAP:
return LoginViaLDAP(user, login, password, source, autoRegister) return LoginViaLDAP(user, login, password, source, autoRegister)
case LoginSmtp:
case LoginSMTP:
return LoginViaSMTP(user, login, password, source.ID, source.Cfg.(*SMTPConfig), autoRegister) return LoginViaSMTP(user, login, password, source.ID, source.Cfg.(*SMTPConfig), autoRegister)
case LoginPam:
case LoginPAM:
return LoginViaPAM(user, login, password, source.ID, source.Cfg.(*PAMConfig), autoRegister) return LoginViaPAM(user, login, password, source.ID, source.Cfg.(*PAMConfig), autoRegister)
} }




if hasUser { if hasUser {
switch user.LoginType { switch user.LoginType {
case LoginNotype, LoginPlain:
case LoginNoType, LoginPlain:
if user.ValidatePassword(passowrd) { if user.ValidatePassword(passowrd) {
return user, nil return user, nil
} }

+ 4
- 4
models/webhook.go Ver fichero

type HookContentType int type HookContentType int


const ( const (
ContentTypeJson HookContentType = iota + 1
ContentTypeJSON HookContentType = iota + 1
ContentTypeForm ContentTypeForm
) )


var hookContentTypes = map[string]HookContentType{ var hookContentTypes = map[string]HookContentType{
"json": ContentTypeJson,
"json": ContentTypeJSON,
"form": ContentTypeForm, "form": ContentTypeForm,
} }




func (t HookContentType) Name() string { func (t HookContentType) Name() string {
switch t { switch t {
case ContentTypeJson:
case ContentTypeJSON:
return "json" return "json"
case ContentTypeForm: case ContentTypeForm:
return "form" return "form"
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify}) SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify})


switch t.ContentType { switch t.ContentType {
case ContentTypeJson:
case ContentTypeJSON:
req = req.Header("Content-Type", "application/json").Body(t.PayloadContent) req = req.Header("Content-Type", "application/json").Body(t.PayloadContent)
case ContentTypeForm: case ContentTypeForm:
req.Param("payload", t.PayloadContent) req.Param("payload", t.PayloadContent)

+ 4
- 4
modules/auth/ldap/ldap.go Ver fichero

// Note: new type must be added at the end of list to maintain compatibility. // Note: new type must be added at the end of list to maintain compatibility.
const ( const (
SecurityProtocolUnencrypted SecurityProtocol = iota SecurityProtocolUnencrypted SecurityProtocol = iota
SecurityProtocolLdaps
SecurityProtocolStartTls
SecurityProtocolLDAPS
SecurityProtocolStartTLS
) )


// Basic LDAP authentication service // Basic LDAP authentication service
ServerName: ls.Host, ServerName: ls.Host,
InsecureSkipVerify: ls.SkipVerify, InsecureSkipVerify: ls.SkipVerify,
} }
if ls.SecurityProtocol == SecurityProtocolLdaps {
if ls.SecurityProtocol == SecurityProtocolLDAPS {
return ldap.DialTLS("tcp", fmt.Sprintf("%s:%d", ls.Host, ls.Port), tlsCfg) return ldap.DialTLS("tcp", fmt.Sprintf("%s:%d", ls.Host, ls.Port), tlsCfg)
} }


return nil, fmt.Errorf("Dial: %v", err) return nil, fmt.Errorf("Dial: %v", err)
} }


if ls.SecurityProtocol == SecurityProtocolStartTls {
if ls.SecurityProtocol == SecurityProtocolStartTLS {
if err = conn.StartTLS(tlsCfg); err != nil { if err = conn.StartTLS(tlsCfg); err != nil {
conn.Close() conn.Close()
return nil, fmt.Errorf("StartTLS: %v", err) return nil, fmt.Errorf("StartTLS: %v", err)

+ 8
- 8
modules/log/smtp.go Ver fichero

) )


// smtpWriter implements LoggerInterface and is used to send emails via given SMTP-server. // smtpWriter implements LoggerInterface and is used to send emails via given SMTP-server.
type SmtpWriter struct {
type SMTPWriter struct {
Username string `json:"Username"` Username string `json:"Username"`
Password string `json:"password"` Password string `json:"password"`
Host string `json:"Host"` Host string `json:"Host"`
} }


// create smtp writer. // create smtp writer.
func NewSmtpWriter() LoggerInterface {
return &SmtpWriter{Level: TRACE}
func NewSMTPWriter() LoggerInterface {
return &SMTPWriter{Level: TRACE}
} }


// init smtp writer with json config. // init smtp writer with json config.
// "sendTos":["email1","email2"], // "sendTos":["email1","email2"],
// "level":LevelError // "level":LevelError
// } // }
func (sw *SmtpWriter) Init(jsonconfig string) error {
func (sw *SMTPWriter) Init(jsonconfig string) error {
return json.Unmarshal([]byte(jsonconfig), sw) return json.Unmarshal([]byte(jsonconfig), sw)
} }


// write message in smtp writer. // write message in smtp writer.
// it will send an email with subject and only this message. // it will send an email with subject and only this message.
func (s *SmtpWriter) WriteMsg(msg string, skip, level int) error {
func (s *SMTPWriter) WriteMsg(msg string, skip, level int) error {
if level < s.Level { if level < s.Level {
return nil return nil
} }
) )
} }


func (_ *SmtpWriter) Flush() {
func (_ *SMTPWriter) Flush() {
} }


func (_ *SmtpWriter) Destroy() {
func (_ *SMTPWriter) Destroy() {
} }


func init() { func init() {
Register("smtp", NewSmtpWriter)
Register("smtp", NewSMTPWriter)
} }

+ 1
- 1
public/css/semantic-2.2.1.min.css
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 14
- 14
routers/admin/auths.go Ver fichero



var ( var (
authSources = []dropdownItem{ authSources = []dropdownItem{
{models.LoginNames[models.LoginLdap], models.LoginLdap},
{models.LoginNames[models.LoginDldap], models.LoginDldap},
{models.LoginNames[models.LoginSmtp], models.LoginSmtp},
{models.LoginNames[models.LoginPam], models.LoginPam},
{models.LoginNames[models.LoginLDAP], models.LoginLDAP},
{models.LoginNames[models.LoginDLDAP], models.LoginDLDAP},
{models.LoginNames[models.LoginSMTP], models.LoginSMTP},
{models.LoginNames[models.LoginPAM], models.LoginPAM},
} }
securityProtocols = []dropdownItem{ securityProtocols = []dropdownItem{
{models.SecurityProtocolNames[ldap.SecurityProtocolUnencrypted], ldap.SecurityProtocolUnencrypted}, {models.SecurityProtocolNames[ldap.SecurityProtocolUnencrypted], ldap.SecurityProtocolUnencrypted},
{models.SecurityProtocolNames[ldap.SecurityProtocolLdaps], ldap.SecurityProtocolLdaps},
{models.SecurityProtocolNames[ldap.SecurityProtocolStartTls], ldap.SecurityProtocolStartTls},
{models.SecurityProtocolNames[ldap.SecurityProtocolLDAPS], ldap.SecurityProtocolLDAPS},
{models.SecurityProtocolNames[ldap.SecurityProtocolStartTLS], ldap.SecurityProtocolStartTLS},
} }
) )


ctx.Data["PageIsAdmin"] = true ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminAuthentications"] = true ctx.Data["PageIsAdminAuthentications"] = true


ctx.Data["type"] = models.LoginLdap
ctx.Data["CurrentTypeName"] = models.LoginNames[models.LoginLdap]
ctx.Data["type"] = models.LoginLDAP
ctx.Data["CurrentTypeName"] = models.LoginNames[models.LoginLDAP]
ctx.Data["CurrentSecurityProtocol"] = models.SecurityProtocolNames[ldap.SecurityProtocolUnencrypted] ctx.Data["CurrentSecurityProtocol"] = models.SecurityProtocolNames[ldap.SecurityProtocolUnencrypted]
ctx.Data["smtp_auth"] = "PLAIN" ctx.Data["smtp_auth"] = "PLAIN"
ctx.Data["is_active"] = true ctx.Data["is_active"] = true
hasTLS := false hasTLS := false
var config core.Conversion var config core.Conversion
switch models.LoginType(form.Type) { switch models.LoginType(form.Type) {
case models.LoginLdap, models.LoginDldap:
case models.LoginLDAP, models.LoginDLDAP:
config = parseLDAPConfig(form) config = parseLDAPConfig(form)
hasTLS = ldap.SecurityProtocol(form.SecurityProtocol) > ldap.SecurityProtocolUnencrypted hasTLS = ldap.SecurityProtocol(form.SecurityProtocol) > ldap.SecurityProtocolUnencrypted
case models.LoginSmtp:
case models.LoginSMTP:
config = parseSMTPConfig(form) config = parseSMTPConfig(form)
hasTLS = true hasTLS = true
case models.LoginPam:
case models.LoginPAM:
config = &models.PAMConfig{ config = &models.PAMConfig{
ServiceName: form.PAMServiceName, ServiceName: form.PAMServiceName,
} }


var config core.Conversion var config core.Conversion
switch models.LoginType(form.Type) { switch models.LoginType(form.Type) {
case models.LoginLdap, models.LoginDldap:
case models.LoginLDAP, models.LoginDLDAP:
config = parseLDAPConfig(form) config = parseLDAPConfig(form)
case models.LoginSmtp:
case models.LoginSMTP:
config = parseSMTPConfig(form) config = parseSMTPConfig(form)
case models.LoginPam:
case models.LoginPAM:
config = &models.PAMConfig{ config = &models.PAMConfig{
ServiceName: form.PAMServiceName, ServiceName: form.PAMServiceName,
} }

+ 23
- 23
routers/repo/setting.go Ver fichero

) )


const ( const (
SETTINGS_OPTIONS base.TplName = "repo/settings/options"
COLLABORATION base.TplName = "repo/settings/collaboration"
GITHOOKS base.TplName = "repo/settings/githooks"
GithookEdit base.TplName = "repo/settings/githook_edit"
DEPLOY_KEYS base.TplName = "repo/settings/deploy_keys"
tplSettingsOptions base.TplName = "repo/settings/options"
tplCollaboration base.TplName = "repo/settings/collaboration"
tplGithooks base.TplName = "repo/settings/githooks"
tplGithookEdit base.TplName = "repo/settings/githook_edit"
tplDeployKeys base.TplName = "repo/settings/deploy_keys"
) )


func Settings(ctx *context.Context) { func Settings(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings") ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsOptions"] = true ctx.Data["PageIsSettingsOptions"] = true
ctx.HTML(200, SETTINGS_OPTIONS)
ctx.HTML(200, tplSettingsOptions)
} }


func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
switch ctx.Query("action") { switch ctx.Query("action") {
case "update": case "update":
if ctx.HasError() { if ctx.HasError() {
ctx.HTML(200, SETTINGS_OPTIONS)
ctx.HTML(200, tplSettingsOptions)
return return
} }


ctx.Data["Err_RepoName"] = true ctx.Data["Err_RepoName"] = true
switch { switch {
case models.IsErrRepoAlreadyExist(err): case models.IsErrRepoAlreadyExist(err):
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), SETTINGS_OPTIONS, &form)
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), tplSettingsOptions, &form)
case models.IsErrNameReserved(err): case models.IsErrNameReserved(err):
ctx.RenderWithErr(ctx.Tr("repo.form.name_reserved", err.(models.ErrNameReserved).Name), SETTINGS_OPTIONS, &form)
ctx.RenderWithErr(ctx.Tr("repo.form.name_reserved", err.(models.ErrNameReserved).Name), tplSettingsOptions, &form)
case models.IsErrNamePatternNotAllowed(err): case models.IsErrNamePatternNotAllowed(err):
ctx.RenderWithErr(ctx.Tr("repo.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), SETTINGS_OPTIONS, &form)
ctx.RenderWithErr(ctx.Tr("repo.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), tplSettingsOptions, &form)
default: default:
ctx.Handle(500, "ChangeRepositoryName", err) ctx.Handle(500, "ChangeRepositoryName", err)
} }
return return
} }
if repo.Name != form.RepoName { if repo.Name != form.RepoName {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil)
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), tplSettingsOptions, nil)
return return
} }


return return
} }
if repo.Name != form.RepoName { if repo.Name != form.RepoName {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil)
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), tplSettingsOptions, nil)
return return
} }


ctx.Handle(500, "IsUserExist", err) ctx.Handle(500, "IsUserExist", err)
return return
} else if !isExist { } else if !isExist {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_owner_name"), SETTINGS_OPTIONS, nil)
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_owner_name"), tplSettingsOptions, nil)
return return
} }


if err = models.TransferOwnership(ctx.User, newOwner, repo); err != nil { if err = models.TransferOwnership(ctx.User, newOwner, repo); err != nil {
if models.IsErrRepoAlreadyExist(err) { if models.IsErrRepoAlreadyExist(err) {
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), SETTINGS_OPTIONS, nil)
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), tplSettingsOptions, nil)
} else { } else {
ctx.Handle(500, "TransferOwnership", err) ctx.Handle(500, "TransferOwnership", err)
} }
return return
} }
if repo.Name != form.RepoName { if repo.Name != form.RepoName {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil)
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), tplSettingsOptions, nil)
return return
} }


return return
} }
if repo.Name != form.RepoName { if repo.Name != form.RepoName {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil)
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), tplSettingsOptions, nil)
return return
} }


} }
ctx.Data["Collaborators"] = users ctx.Data["Collaborators"] = users


ctx.HTML(200, COLLABORATION)
ctx.HTML(200, tplCollaboration)
} }


func CollaborationPost(ctx *context.Context) { func CollaborationPost(ctx *context.Context) {
} }
ctx.Data["Hooks"] = hooks ctx.Data["Hooks"] = hooks


ctx.HTML(200, GITHOOKS)
ctx.HTML(200, tplGithooks)
} }


func GitHooksEdit(ctx *context.Context) { func GitHooksEdit(ctx *context.Context) {
return return
} }
ctx.Data["Hook"] = hook ctx.Data["Hook"] = hook
ctx.HTML(200, GithookEdit)
ctx.HTML(200, tplGithookEdit)
} }


func GitHooksEditPost(ctx *context.Context) { func GitHooksEditPost(ctx *context.Context) {
} }
ctx.Data["Deploykeys"] = keys ctx.Data["Deploykeys"] = keys


ctx.HTML(200, DEPLOY_KEYS)
ctx.HTML(200, tplDeployKeys)
} }


func DeployKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) { func DeployKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) {
ctx.Data["Deploykeys"] = keys ctx.Data["Deploykeys"] = keys


if ctx.HasError() { if ctx.HasError() {
ctx.HTML(200, DEPLOY_KEYS)
ctx.HTML(200, tplDeployKeys)
return return
} }


switch { switch {
case models.IsErrKeyAlreadyExist(err): case models.IsErrKeyAlreadyExist(err):
ctx.Data["Err_Content"] = true ctx.Data["Err_Content"] = true
ctx.RenderWithErr(ctx.Tr("repo.settings.key_been_used"), DEPLOY_KEYS, &form)
ctx.RenderWithErr(ctx.Tr("repo.settings.key_been_used"), tplDeployKeys, &form)
case models.IsErrKeyNameAlreadyUsed(err): case models.IsErrKeyNameAlreadyUsed(err):
ctx.Data["Err_Title"] = true ctx.Data["Err_Title"] = true
ctx.RenderWithErr(ctx.Tr("repo.settings.key_name_used"), DEPLOY_KEYS, &form)
ctx.RenderWithErr(ctx.Tr("repo.settings.key_name_used"), tplDeployKeys, &form)
default: default:
ctx.Handle(500, "AddDeployKey", err) ctx.Handle(500, "AddDeployKey", err)
} }

+ 9
- 9
routers/repo/webhook.go Ver fichero

) )


const ( const (
HOOKS base.TplName = "repo/settings/hooks"
HookNew base.TplName = "repo/settings/hook_new"
ORG_HookNew base.TplName = "org/settings/hook_new"
tplHooks base.TplName = "repo/settings/hooks"
tplHookNew base.TplName = "repo/settings/hook_new"
tplOrgHookNew base.TplName = "org/settings/hook_new"
) )


func Webhooks(ctx *context.Context) { func Webhooks(ctx *context.Context) {
} }
ctx.Data["Webhooks"] = ws ctx.Data["Webhooks"] = ws


ctx.HTML(200, HOOKS)
ctx.HTML(200, tplHooks)
} }


type OrgRepoCtx struct { type OrgRepoCtx struct {
return &OrgRepoCtx{ return &OrgRepoCtx{
RepoID: ctx.Repo.Repository.ID, RepoID: ctx.Repo.Repository.ID,
Link: ctx.Repo.RepoLink, Link: ctx.Repo.RepoLink,
NewTemplate: HookNew,
NewTemplate: tplHookNew,
}, nil }, nil
} }


return &OrgRepoCtx{ return &OrgRepoCtx{
OrgID: ctx.Org.Organization.ID, OrgID: ctx.Org.Organization.ID,
Link: ctx.Org.OrgLink, Link: ctx.Org.OrgLink,
NewTemplate: ORG_HookNew,
NewTemplate: tplOrgHookNew,
}, nil }, nil
} }


return return
} }


contentType := models.ContentTypeJson
contentType := models.ContentTypeJSON
if models.HookContentType(form.ContentType) == models.ContentTypeForm { if models.HookContentType(form.ContentType) == models.ContentTypeForm {
contentType = models.ContentTypeForm contentType = models.ContentTypeForm
} }
w := &models.Webhook{ w := &models.Webhook{
RepoID: orCtx.RepoID, RepoID: orCtx.RepoID,
URL: form.PayloadURL, URL: form.PayloadURL,
ContentType: models.ContentTypeJson,
ContentType: models.ContentTypeJSON,
HookEvent: ParseHookEvent(form.WebhookForm), HookEvent: ParseHookEvent(form.WebhookForm),
IsActive: form.Active, IsActive: form.Active,
HookTaskType: models.SLACK, HookTaskType: models.SLACK,
return return
} }


contentType := models.ContentTypeJson
contentType := models.ContentTypeJSON
if models.HookContentType(form.ContentType) == models.ContentTypeForm { if models.HookContentType(form.ContentType) == models.ContentTypeForm {
contentType = models.ContentTypeForm contentType = models.ContentTypeForm
} }

+ 1
- 1
vendor/gopkg.in/ldap.v2/ldap.go Ver fichero

ApplicationExtendedResponse: "Extended Response", ApplicationExtendedResponse: "Extended Response",
} }


// Ldap Behera Password Policy Draft 10 (https://tools.ietf.org/html/draft-behera-ldap-password-policy-10)
// LDAP Behera Password Policy Draft 10 (https://tools.ietf.org/html/draft-behera-ldap-password-policy-10)
const ( const (
BeheraPasswordExpired = 0 BeheraPasswordExpired = 0
BeheraAccountLocked = 1 BeheraAccountLocked = 1

Cargando…
Cancelar
Guardar