本文整理匯總了Golang中github.com/xyproto/pinterface.IUserState.RemoveUser方法的典型用法代碼示例。如果您正苦於以下問題:Golang IUserState.RemoveUser方法的具體用法?Golang IUserState.RemoveUser怎麽用?Golang IUserState.RemoveUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/xyproto/pinterface.IUserState
的用法示例。
在下文中一共展示了IUserState.RemoveUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GenerateRemoveUser
// TODO: Undo for removing users
// Remove a user
func GenerateRemoveUser(state pinterface.IUserState) WebHandle {
return func(ctx *web.Context, username string) string {
if !state.AdminRights(ctx.Request) {
return MessageOKback("Remove user", "Not logged in as Administrator")
}
if username == "" {
return MessageOKback("Remove user", "Can't remove blank user")
}
if !state.HasUser(username) {
return MessageOKback("Remove user", username+" doesn't exists, could not remove")
}
// Remove the user
state.RemoveUser(username)
return MessageOKurl("Remove user", "OK, removed "+username, "/admin")
}
}
示例2: exportUserstate
//.........這裏部分代碼省略.........
var result lua.LString
if err != nil {
result = lua.LString("")
} else {
result = lua.LString(pw)
}
L.Push(result)
return 1 // number of results
}))
// Add a user to the list of unconfirmed users, returns nothing
// Takes a username and a confirmation code
L.SetGlobal("AddUnconfirmed", L.NewFunction(func(L *lua.LState) int {
username := L.ToString(1)
confirmationCode := L.ToString(2)
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)