本文整理汇总了Golang中github.com/xyproto/pinterface.IUserState.RemoveAdminStatus方法的典型用法代码示例。如果您正苦于以下问题:Golang IUserState.RemoveAdminStatus方法的具体用法?Golang IUserState.RemoveAdminStatus怎么用?Golang IUserState.RemoveAdminStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/xyproto/pinterface.IUserState
的用法示例。
在下文中一共展示了IUserState.RemoveAdminStatus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GenerateToggleAdmin
func GenerateToggleAdmin(state pinterface.IUserState) WebHandle {
return func(ctx *web.Context, username string) string {
if !state.AdminRights(ctx.Request) {
return MessageOKback("Admin toggle", "Not logged in as Administrator")
}
if username == "" {
return MessageOKback("Admin toggle", "Can't set toggle empty username")
}
if !state.HasUser(username) {
return MessageOKback("Admin toggle", "Can't toggle non-existing user")
}
// A special case
if username == "admin" {
return MessageOKback("Admin toggle", "Can't remove admin rights from the admin user")
}
if !state.IsAdmin(username) {
state.SetAdminStatus(username)
return MessageOKurl("Admin toggle", "OK, "+username+" is now an admin", "/admin")
}
state.RemoveAdminStatus(username)
return MessageOKurl("Admin toggle", "OK, "+username+" is now a regular user", "/admin")
}
}
示例2: exportUserstate
//.........这里部分代码省略.........
userstate.AddUnconfirmed(username, confirmationCode)
return 0 // number of results
}))
// Remove a user from the list of unconfirmed users, returns nothing
// Takes a username
L.SetGlobal("RemoveUnconfirmed", L.NewFunction(func(L *lua.LState) int {
username := L.ToString(1)
userstate.RemoveUnconfirmed(username)
return 0 // number of results
}))
// Mark a user as confirmed, returns nothing
// Takes a username
L.SetGlobal("MarkConfirmed", L.NewFunction(func(L *lua.LState) int {
username := L.ToString(1)
userstate.MarkConfirmed(username)
return 0 // number of results
}))
// Removes a user, returns nothing
// Takes a username
L.SetGlobal("RemoveUser", L.NewFunction(func(L *lua.LState) int {
username := L.ToString(1)
userstate.RemoveUser(username)
return 0 // number of results
}))
// Make a user an admin, returns nothing
// Takes a username
L.SetGlobal("SetAdminStatus", L.NewFunction(func(L *lua.LState) int {
username := L.ToString(1)
userstate.SetAdminStatus(username)
return 0 // number of results
}))
// Make an admin user a regular user, returns nothing
// Takes a username
L.SetGlobal("RemoveAdminStatus", L.NewFunction(func(L *lua.LState) int {
username := L.ToString(1)
userstate.RemoveAdminStatus(username)
return 0 // number of results
}))
// Add a user, returns nothing
// Takes a username, password and email
L.SetGlobal("AddUser", L.NewFunction(func(L *lua.LState) int {
username := L.ToString(1)
password := L.ToString(2)
email := L.ToString(3)
userstate.AddUser(username, password, email)
return 0 // number of results
}))
// Set a user as logged in on the server (not cookie), returns nothing
// Takes a username
L.SetGlobal("SetLoggedIn", L.NewFunction(func(L *lua.LState) int {
username := L.ToString(1)
userstate.SetLoggedIn(username)
return 0 // number of results
}))
// Set a user as logged out on the server (not cookie), returns nothing
// Takes a username
L.SetGlobal("SetLoggedOut", L.NewFunction(func(L *lua.LState) int {
username := L.ToString(1)
userstate.SetLoggedOut(username)
return 0 // number of results
}))
// Log in a user, both on the server and with a cookie.
// Returns true of successful.
// Takes a username
L.SetGlobal("Login", L.NewFunction(func(L *lua.LState) int {
username := L.ToString(1)