[英]Inserting email into auth_user in web2py on first time login while using pam_auth
我正在為我的web2py安裝使用pam_auth登錄。 當用戶首次登錄時,我想存儲從ldap查詢中獲取的他的電子郵件。 我該如何在web2py中做到這一點。
換句話說,我想在任何用戶首次登錄時在python中執行一個ldap查詢。
web2py默認身份驗證系統具有事件表,該表存儲用戶的每個事件。 即它存儲用於注冊,登錄,注銷等的事件。
因此,您可以通過查詢該表來查看這是否是首次登錄。
USER_ID = #Get your user ID
query = (db.auth_event.description.like('%Logged-in%'))&(db.auth_event.user_id==USER_ID)
if db(query).count() == 1:
#this is the first login of this user
ldap_mail = #Call LDAP to get the email
#store the email adress in auth_user
db(db.auth_user.id==USER_ID).update(email=ldap_mail)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.