38 lines
634 B
Go
38 lines
634 B
Go
package main
|
|
|
|
func inArray(id int64, ids []int64) bool {
|
|
for _, v := range ids {
|
|
if v == id {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (ctx *Context) isAuth(id int64) bool {
|
|
if ctx.Settings.Admin == id {
|
|
return true
|
|
}
|
|
if len(ctx.Settings.Blacklist) > 0 {
|
|
if inArray(id, ctx.Settings.Blacklist) {
|
|
return false
|
|
}
|
|
}
|
|
if len(ctx.PassedPasswordCheck) > 0 {
|
|
if inArray(id, ctx.PassedPasswordCheck) {
|
|
return true
|
|
}
|
|
}
|
|
if len(ctx.Settings.Whitelist) > 0 {
|
|
if inArray(id, ctx.Settings.Whitelist) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
if ctx.Settings.Password == "" {
|
|
return true
|
|
}
|
|
return false
|
|
}
|