Open source cms for mobile and desktop websites

nive_userdb.app

nive user database

You can specify a admin user on configuration level as admin. The admin user works without database connection.

The system admin for notification mails can be specified as systemAdmin.

configuration.admin = {"name": "admin", "password": "adminpass", "email": "admin@domain.com"}
configuration.systemAdmin = (u"email", u"display name")
class nive_userdb.app.UserDB(configuration=None)
Groupfinder(userid, request=None, context=None)

returns the list of groups assigned to the user

RememberLogin(request, user)

add login info to cookies or session.

ForgetLogin(request, url=None)

removes login info from cookies and session

nive_userdb.app.IsReservedUserName(name)

Check if name can be used for users

nive_userdb.app.UsernameValidator(node, value)

Validator which succeeds if the username does not exist. Can be used for the name input field in a sign up form.

nive_userdb.app.EmailValidator(node, value)

Validator which succeeds if the email does not exist. Can be used for the email input field in a sign up form.

nive_userdb.app.PasswordValidator(node, value)

Validator which succeeds if the username does not exist. Can be used for the name input field in a sign up form.

nive_userdb.app.OldPwValidator(node, value)

Validator which succeeds if the current password matches.

nive_userdb (objects)

Root for public user functions

Provides functionality to safely add users with several activation and mailing options.

class nive_userdb.root.root(path, app, rootDef)
AddUser(data, activate=None, generatePW=None, generateName=None, mail='default', notifyMail='default', groups=None, currentUser=None, **kw)

Create a new user with groups for login with name/password

data: user data as dictionary. groups and pool_state are removed. 
activate: directly activate the user for login (pool_state=1)
generatePW: generate a random password to be send by mail
generateName: generate a unique id to be used as username
mail: mail object template for confirmation mail
notifyMail: mail object template for notify mail
groups: initially assign groups to the user
currentUser: the currently logged in user for pool_createdby and workflow

returns tuple: the user object if succeeds and report list

Login(name, password, raiseUnauthorized=1)

returns user/none and report list

Logout(ident)

Logout and delete session data

MailVerifyNewEmail(name, newmail, mail='default', currentUser=None, **kw)

returns status and report list

MailUserPass(name, mail='default', newPassword=None, currentUser=None, **kw)

Mails a new password or the current password in plain text.

returns status and report list

MailResetPass(name, mail='default', currentUser=None, **kw)

returns status and report list

DeleteUser(ident, currentUser=None)

returns status and report list

GetUser(ident, activeOnly=1)

Lookup user by user identity as used in session cookies for example. Returns the cached session user if available, not the ‘real’ user object. Use LookupUser() to make sure the user is actually looked in the database.

events: - getuser(ident, activeOnly) - loaduser(user)

GetUserByName(name, activeOnly=1)
GetUserByMail(email, activeOnly=1)
GetUserByID(id, activeOnly=1)
LookupUser(id=None, ident=None, name=None, email=None, activeOnly=1, reloadFromDB=0)

reloadFromDB deprecated. will be removed in the future

GetUserForToken(token, activeOnly=True)

Looks up the user for the token requires fld token in user record returns tuple: the user object or None

GetUsers(**kw)
GetUserInfos(userids, fields=None, activeOnly=True)
GetUsersWithGroup(group, fields=None, activeOnly=True)
GetUserGroups(name, activeOnly=1)
class nive_userdb.user.user(id, dbEntry, parent, configuration, **kw)

User object with groups and login possibility.

Activate(currentUser)

Activate user and remove activation id calls workflow commit, if possible

signals event: activate

DeActivate(currentUser)

DeActivate user calls workflow commit, if possible

signals event: activate

Login()

events: login(lastlogin)

Logout()

events: logout()

SecureUpdate(data, user)

Update existing user data. name, groups, pool_state cannot be changed

UpdatePassword(password, user, resetActivation=True)

Update existing user data. changes the password and resets the token

UpdateEmail(email, user, resetActivation=True)

Update existing user data. changes the email and resets the token

UpdateGroups(groups)

update groups of user

AddGroup(group, user=None)

add user to this group

event: securityCahnged()

RemoveGroup(group)

add user to this group

event: securityCahnged()

GetGroups(context=None)

Returns the users gloabal groups as tuple. Local assignments are not supported, context is currently unused.

InGroups(groups)

check if user has one of these groups

© 2013 Nive GmbH