Skip to content

Instantly share code, notes, and snippets.

@eight

eight/gist:227564

Created Nov 6, 2009
Embed
What would you like to do?
# -*- coding: utf-8 -*-
"""MoinMoin custom user authentication sample
"""
from MoinMoin import user
#User Database
_USER_MAP = {'user1,pass1':('user1@example.com',u'user1'),'user2,pass2':('user2@example.com','user2')}
def login(request, **kw):
username = kw.get('name')
password = kw.get('password')
login = kw.get('login')
user_obj = kw.get('user_obj')
if not login:
return user_obj, True
u = None
user_info = _USER_MAP.get("%s,%s" % (username,password),False)
if user_info:
u = user.User(request,
name=username,
auth_username=username,
password=password,
auth_method='myauth',
auth_attribs=('name', 'auth_username', 'password', 'email', 'aliasname', ))
u.email = user_info[0]
u.aliasname = user_info[1]
u.create_or_update(True)
request.log("Login OK. user=%s, email=%s, aliasname=%s." % (username,user_info[0],user_info[1]))
return u, True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.