Skip to content

Instantly share code, notes, and snippets.

@eight
Created November 6, 2009 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eight/227564 to your computer and use it in GitHub Desktop.
Save eight/227564 to your computer and use it in GitHub Desktop.
# -*- 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