diff --git a/modules/websession/lib/webaccount.py b/modules/websession/lib/webaccount.py
index 1359a9ba6..2d380159e 100644
--- a/modules/websession/lib/webaccount.py
+++ b/modules/websession/lib/webaccount.py
@@ -1,329 +1,364 @@
## $Id$
## CDSware User account information implementation. Useful for youraccount pages.
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
## read config variables:
#include "config.wml"
#include "configbis.wml"
import sys
import string
import cgi
from config import *
from webpage import page
from dbquery import run_sql
from webuser import getUid,isGuestUser
from access_control_admin import acc_findUserRoleActions
from access_control_config import CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS
imagesurl = "%s/img" % weburl
# perform_info(): display the main features of CDS personalize
def perform_info(req):
out = ""
uid = getUid(req)
out += """
The CDS Search offers you a possibility to personalize the interface, to set up your own personal library
of documents, or to set up an automatic alert query that would run periodically and would notify you of search
results by email.
-
Your Settings
- Set or change your account Email address or password.
Specify your preferences about the way the interface looks like.
- Your Searches
- View all the searches you performed during the last 30 days.
- Your Baskets
- With baskets you can define specific collections of items,
store interesting records you want to access later or share with others."""
if isGuestUser(uid):
out+= warning_guest_user(type="baskets")
out += """
- Your Alerts
- Subscribe to a search which will be run periodically by our service. The result can be sent to you
via Email or stored in one of your baskets."""
if isGuestUser(uid):
out+= warning_guest_user(type="alerts")
if cfg_cern_site:
out += """
- Your Loans
- Check out book you have on load, submit borrowing requests, etc. Requires CERN ID."""
out += """
"""
return out
def perform_youradminactivities(uid):
"""Return text for the `Your Admin Activities' box. Analyze
whether user UID has some admin roles, and if yes, then print
suitable links for the actions he can do. If he's not admin,
print a simple non-authorized message."""
if isGuestUser(uid):
return """You seem to be the guest user. You have to login first."""
out = ""
your_role_actions = acc_findUserRoleActions(uid)
your_roles = []
your_admin_activities = []
for (role, action) in your_role_actions:
if role not in your_roles:
your_roles.append(role)
if not your_roles:
out += "You are not authorized to access administrative functions."
else:
out += "
You seem to be %s. " % string.join(your_roles, ", ")
out += "Here are some interesting web admin links for you:"
# add actions found by the RBAC:
for (role, action) in your_role_actions:
if action not in your_admin_activities:
your_admin_activities.append(action)
# add all actions if user is superadmin, to make sure he'll see all
# (since it is not necessary for the superadmin to be connected to actions in RBAC tables):
if "superadmin" in your_roles:
for action in ["cfgbibformat", "cfgbibrank", "cfgbibindex", "cfgwebaccess", "cfgwebsearch", "cfgwebsubmit"]:
if action not in your_admin_activities:
your_admin_activities.append(action)
# print proposed links:
for action in your_admin_activities:
if action == "cfgbibformat":
out += """
Configure BibFormat""" % weburl
if action == "cfgbibrank":
out += """
Configure BibRank""" % weburl
if action == "cfgbibindex":
out += """
Configure BibIndex""" % weburl
if action == "cfgwebaccess":
out += """
Configure WebAccess""" % weburl
if action == "cfgwebsearch":
out += """
Configure WebSearch""" % weburl
if action == "cfgwebsubmit":
out += """
Configure WebSubmit""" % weburl
out += """
For more admin-level activities, see the complete Admin Area.""" % weburl
return out
# perform_display_account(): display a dynamic page that shows the user's account
def perform_display_account(req,data,bask,aler,sear):
uid = getUid(req)
#your account
if isGuestUser(uid):
user ="guest"
accBody = """You are logged in as guest. You may want to login as a regular user
"""
bask=aler="""The guest users need to register first"""
sear="No queries found"
else:
user = data[0]
accBody ="""You are logged in as %s. You may want to a) logout; b) edit your email address or password.
"""%user
out =""
out +=template_account("Your Account",accBody)
#your baskets
out +=template_account("Your Baskets",bask)
out +=template_account("Your Alert Searches",aler)
out +=template_account("Your Searches",sear)
out +=template_account("Your Submissions",
"""You can consult the list of your submissions
and inquire about their status.""" % weburl)
out +=template_account("Your Approvals",
"""You can consult the list of your approvals
with the documents you approved or refereed.""" % weburl)
out +=template_account("Your Administrative Activities", perform_youradminactivities(uid))
return out
# template_account() : it is a template for print each of the options from the user's account
def template_account(title,body):
out =""
out +="""
""" % (title, body)
return out
# warning_guest_user(): It returns an alert message,showing that the user is a guest user and should log into the system
def warning_guest_user(type):
msg="""You are logged in as a guest user, so your %s will disappear at the end of the current session. If you wish you can
login or register here.
"""%type
return """""" % msg
## perform_delete():delete the account of the user, not implement yet
def perform_delete():
out = """Deleting your account"""
return out
## perform_set(email,password): edit your account parameters, email and password.
def perform_set(email,password):
text = """
Edit account parameters
"""%(email,password)
return text
-
-## perform_ask(): ask for the user's email and password, for login into the system
-def perform_ask(referer=''):
- text = """
- If you already have an account, please log in by choosing the login
- button below.
"""
+
+## create_register_page_box(): register a new account
+def create_register_page_box(referer=''):
+
+ text = ""
if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS <= 1:
- text += """If you don't own an account yet, please enter the values of your preference and choose the register button."""
+ text += """Please enter the values of your preference and choose the register button."""
if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS == 1:
text += "The account will not be possible to use before it has been verified and activated."
elif CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 2:
text += """It is not possible to create an account yourself. Contact if you want an account."""
text += """
-
""" % (cdsname)
return text
# perform_logout: display the message of not longer authorized,
def perform_logout(req):
out =""
out+="""
You are no longer recognized. If you wish you can login here.
"""
return out
#def perform_lost: ask the user for his email, in order to send him the lost password
def perform_lost():
out =""
out +="""
Lost your password?
"""%imagesurl
return out
# perform_emailSent(email): confirm that the password has been emailed to 'email' address
def perform_emailSent(email):
out =""
out +="Okay, password has been emailed to %s"%email
return out
# peform_emailMessage : display a error message when the email introduced is not correct, and sugest to try again
def perform_emailMessage(eMsg):
out =""
out +="""
%s Try again
"""%eMsg
return out
# perform_back(): template for return to a previous page, used for login,register and setting
def perform_back(mess,act):
out =""
out+="""
"""%(mess,act,act)
return out
diff --git a/modules/websession/lib/webaccount.py.wml b/modules/websession/lib/webaccount.py.wml
index 1359a9ba6..2d380159e 100644
--- a/modules/websession/lib/webaccount.py.wml
+++ b/modules/websession/lib/webaccount.py.wml
@@ -1,329 +1,364 @@
## $Id$
## CDSware User account information implementation. Useful for youraccount pages.
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
## read config variables:
#include "config.wml"
#include "configbis.wml"
import sys
import string
import cgi
from config import *
from webpage import page
from dbquery import run_sql
from webuser import getUid,isGuestUser
from access_control_admin import acc_findUserRoleActions
from access_control_config import CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS
imagesurl = "%s/img" % weburl
# perform_info(): display the main features of CDS personalize
def perform_info(req):
out = ""
uid = getUid(req)
out += """The CDS Search offers you a possibility to personalize the interface, to set up your own personal library
of documents, or to set up an automatic alert query that would run periodically and would notify you of search
results by email.
-
Your Settings
- Set or change your account Email address or password.
Specify your preferences about the way the interface looks like.
- Your Searches
- View all the searches you performed during the last 30 days.
- Your Baskets
- With baskets you can define specific collections of items,
store interesting records you want to access later or share with others."""
if isGuestUser(uid):
out+= warning_guest_user(type="baskets")
out += """
- Your Alerts
- Subscribe to a search which will be run periodically by our service. The result can be sent to you
via Email or stored in one of your baskets."""
if isGuestUser(uid):
out+= warning_guest_user(type="alerts")
if cfg_cern_site:
out += """
- Your Loans
- Check out book you have on load, submit borrowing requests, etc. Requires CERN ID."""
out += """
"""
return out
def perform_youradminactivities(uid):
"""Return text for the `Your Admin Activities' box. Analyze
whether user UID has some admin roles, and if yes, then print
suitable links for the actions he can do. If he's not admin,
print a simple non-authorized message."""
if isGuestUser(uid):
return """You seem to be the guest user. You have to login first."""
out = ""
your_role_actions = acc_findUserRoleActions(uid)
your_roles = []
your_admin_activities = []
for (role, action) in your_role_actions:
if role not in your_roles:
your_roles.append(role)
if not your_roles:
out += "You are not authorized to access administrative functions."
else:
out += "
You seem to be %s. " % string.join(your_roles, ", ")
out += "Here are some interesting web admin links for you:"
# add actions found by the RBAC:
for (role, action) in your_role_actions:
if action not in your_admin_activities:
your_admin_activities.append(action)
# add all actions if user is superadmin, to make sure he'll see all
# (since it is not necessary for the superadmin to be connected to actions in RBAC tables):
if "superadmin" in your_roles:
for action in ["cfgbibformat", "cfgbibrank", "cfgbibindex", "cfgwebaccess", "cfgwebsearch", "cfgwebsubmit"]:
if action not in your_admin_activities:
your_admin_activities.append(action)
# print proposed links:
for action in your_admin_activities:
if action == "cfgbibformat":
out += """
Configure BibFormat""" % weburl
if action == "cfgbibrank":
out += """
Configure BibRank""" % weburl
if action == "cfgbibindex":
out += """
Configure BibIndex""" % weburl
if action == "cfgwebaccess":
out += """
Configure WebAccess""" % weburl
if action == "cfgwebsearch":
out += """
Configure WebSearch""" % weburl
if action == "cfgwebsubmit":
out += """
Configure WebSubmit""" % weburl
out += """
For more admin-level activities, see the complete Admin Area.""" % weburl
return out
# perform_display_account(): display a dynamic page that shows the user's account
def perform_display_account(req,data,bask,aler,sear):
uid = getUid(req)
#your account
if isGuestUser(uid):
user ="guest"
accBody = """You are logged in as guest. You may want to login as a regular user
"""
bask=aler="""The guest users need to register first"""
sear="No queries found"
else:
user = data[0]
accBody ="""You are logged in as %s. You may want to a) logout; b) edit your email address or password.
"""%user
out =""
out +=template_account("Your Account",accBody)
#your baskets
out +=template_account("Your Baskets",bask)
out +=template_account("Your Alert Searches",aler)
out +=template_account("Your Searches",sear)
out +=template_account("Your Submissions",
"""You can consult the list of your submissions
and inquire about their status.""" % weburl)
out +=template_account("Your Approvals",
"""You can consult the list of your approvals
with the documents you approved or refereed.""" % weburl)
out +=template_account("Your Administrative Activities", perform_youradminactivities(uid))
return out
# template_account() : it is a template for print each of the options from the user's account
def template_account(title,body):
out =""
out +="""
""" % (title, body)
return out
# warning_guest_user(): It returns an alert message,showing that the user is a guest user and should log into the system
def warning_guest_user(type):
msg="""You are logged in as a guest user, so your %s will disappear at the end of the current session. If you wish you can
login or register here.
"""%type
return """""" % msg
## perform_delete():delete the account of the user, not implement yet
def perform_delete():
out = """Deleting your account"""
return out
## perform_set(email,password): edit your account parameters, email and password.
def perform_set(email,password):
text = """
Edit account parameters
"""%(email,password)
return text
-
-## perform_ask(): ask for the user's email and password, for login into the system
-def perform_ask(referer=''):
- text = """
- If you already have an account, please log in by choosing the login
- button below.
"""
+
+## create_register_page_box(): register a new account
+def create_register_page_box(referer=''):
+
+ text = ""
if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS <= 1:
- text += """If you don't own an account yet, please enter the values of your preference and choose the register button."""
+ text += """Please enter the values of your preference and choose the register button."""
if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS == 1:
text += "The account will not be possible to use before it has been verified and activated."
elif CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 2:
text += """It is not possible to create an account yourself. Contact if you want an account."""
text += """
-
""" % (cdsname)
return text
# perform_logout: display the message of not longer authorized,
def perform_logout(req):
out =""
out+="""
You are no longer recognized. If you wish you can login here.
"""
return out
#def perform_lost: ask the user for his email, in order to send him the lost password
def perform_lost():
out =""
out +="""
Lost your password?
"""%imagesurl
return out
# perform_emailSent(email): confirm that the password has been emailed to 'email' address
def perform_emailSent(email):
out =""
out +="Okay, password has been emailed to %s"%email
return out
# peform_emailMessage : display a error message when the email introduced is not correct, and sugest to try again
def perform_emailMessage(eMsg):
out =""
out +="""
%s Try again
"""%eMsg
return out
# perform_back(): template for return to a previous page, used for login,register and setting
def perform_back(mess,act):
out =""
out+="""
"""%(mess,act,act)
return out
diff --git a/modules/websession/web/youraccount.py b/modules/websession/web/youraccount.py
index d3df669bb..2d15f764f 100644
--- a/modules/websession/web/youraccount.py
+++ b/modules/websession/web/youraccount.py
@@ -1,289 +1,314 @@
## $Id$
## CDSware User account information.
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## read config variables:
#include "config.wml"
#include "configbis.wml"
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
"""CDSware ACCOUNT HANDLING"""
__lastupdated__ = """<: print `date +"%d %b %Y %H:%M:%S %Z"`; :>"""
## fill config variables:
pylibdir = "/python"
import sys
sys.path.append('%s' % pylibdir)
from cdsware import webuser
from cdsware.config import weburl,cdsname,cdslang,supportemail
from cdsware.webpage import page
from cdsware import webaccount
from cdsware import webbasket
from cdsware import webalert
from cdsware import webuser
from cdsware.access_control_config import *
from mod_python import apache
import smtplib
def set(req, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/set")
data = webuser.getDataUid(req,uid)
email = data[0]
passw = data[1]
return page(title="Your Settings",
body=webaccount.perform_set(email,passw),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Your Settings",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def change(req,email=None,password=None,ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/change")
if webuser.checkemail(email):
change = webuser.updateDataUser(req,uid,email,password)
return display(req, ln)
else :
return display(req, ln)
def lost(req, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/lost")
return page(title="Login",
body=webaccount.perform_lost(),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def display(req, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/display")
if webuser.isGuestUser(uid):
return page(title="Your Account",
body=webaccount.perform_info(req),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
data = webuser.getDataUid(req,uid)
bask = webbasket.account_list_baskets(uid)
aler = webalert.account_list_alerts(uid)
sear = webalert.account_list_searches(uid)
return page(title="Your Account",
body=webaccount.perform_display_account(req,data,bask,aler,sear),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def send_email(req, p_email=None, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/send_email")
passw = webuser.givePassword(p_email)
if passw == -999:
eMsg = "The entered e-mail address doesn't exist in the database"
return page(title="Your Account",
body=webaccount.perform_emailMessage(eMsg),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
fromaddr = "From: %s" % supportemail
toaddrs = "To: " + p_email
to = toaddrs + "\n"
sub = "Subject: Credentials for %s\n\n" % cdsname
body = "Here are your user credentials for %s:\n\n" % cdsname
body += " username: %s\n password: %s\n\n" % (p_email, passw)
body += "You can login at %s/youraccount.py/login" % weburl
msg = to + sub + body
server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
try:
server.sendmail(fromaddr, toaddrs, msg)
except smtplib.SMTPRecipientsRefused,e:
eMsg = "The entered e-mail address is incorrect, please check that it is written correctly (e.g. johndoe@example.com)"
return page(title="Your Account",
body=webaccount.perform_emailMessage(eMsg),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
server.quit()
return page(title="Your Account",
body=webaccount.perform_emailSent(p_email),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def youradminactivities(req, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/youradminactivities")
return page(title="Your Administrative Activities",
body=webaccount.perform_youradminactivities(uid),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def delete(req, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/delete")
return page(title="Delete Account",
body=webaccount.perform_delete(),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def logout(req, ln=cdslang):
uid = webuser.logoutUser(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/logout")
return page(title="Logout",
body=webaccount.perform_logout(req),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def login(req, p_email=None, p_pw=None, action='login', referer='', ln=cdslang):
uid = webuser.getUid(req)
- if action =='login':
-
+ if action =='register':
+ return page(title="Register",
+ body=webaccount.create_register_page_box(referer),
+ navtrail="""Your Account""" % (weburl, ln),
+ description="CDS Personalize, Main page",
+ keywords="CDS, personalize",
+ uid=uid,
+ language=ln,
+ lastupdated=__lastupdated__)
+ elif action =='login':
if p_email==None:
return page(title="Login",
- body=webaccount.perform_ask(referer),
+ body=webaccount.create_login_page_box(referer),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
iden = webuser.loginUser(p_email,p_pw)
if len(iden)>0:
uid = webuser.update_Uid(req,p_email,p_pw)
uid2 = webuser.getUid(req)
if uid2 == -1:
webuser.logoutUser(req)
return webuser.page_not_authorized(req, "../youraccount.py/login?ln=%s" % ln, uid=uid)
# login successful!
if referer:
req.err_headers_out.add("Location", referer)
raise apache.SERVER_RETURN, apache.HTTP_MOVED_PERMANENTLY
else:
return display(req)
else:
if webuser.userNotExist(p_email,p_pw) or p_email=='' or p_email==' ':
mess ="Your are not logged into the system, because this user is unknown."
else:
mess ="Your are not logged into the system, because you have introduced a wrong password."
act = "login"
return page(title="Login",
body=webaccount.perform_back(mess,act),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
+
+def register(req, p_email=None, p_pw=None, action='login', referer='', ln=cdslang):
+ uid = webuser.getUid(req)
+
+ if p_email==None:
+ return page(title="Register",
+ body=webaccount.create_register_page_box(referer),
+ navtrail="""Your Account""" % (weburl, ln),
+ description="CDS Personalize, Main page",
+ keywords="CDS, personalize",
+ uid=uid,
+ language=ln,
+ lastupdated=__lastupdated__)
+
+ mess=""
+ act=""
+ ruid=webuser.registerUser(req,p_email,p_pw)
+ if ruid==1:
+ uid=webuser.update_Uid(req,p_email,p_pw)
+ mess = "Your account has been successfully created."
+ title = "Account created"
+ if CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT == 1:
+ mess += " An email has been sent to the given address with the account information."
+ if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 1:
+ mess += " A second email will be sent when the account has been activated and can be used."
+ else:
+ mess += """ To continue to your account, press here""" % (weburl, ln)
+ elif ruid ==-1 :
+ mess ="The user already exists in the database, please try again"
+ act = "register"
+ title = "Register failure"
else:
- mess=""
- act=""
- ruid=webuser.registerUser(req,p_email,p_pw)
- if ruid==1:
- uid=webuser.update_Uid(req,p_email,p_pw)
- mess = "Your account has been successfully created."
- if CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT == 1:
- mess += " An email has been sent to the given address with the account information."
- if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 1:
- mess += " A second email will be sent when the account has been activated and can be used."
- else:
- mess += """ To continue to your account, press here""" % (weburl, ln)
- elif ruid ==-1 :
- mess ="The user already exists in the database, please try again"
- act = "login"
- else:
- mess ="Your are not registered into the system please try again"
- act = "login"
- return page(title="Register failure",
- body=webaccount.perform_back(mess,act),
- navtrail="""Your Account""" % (weburl, ln),
- description="CDS Personalize, Main page",
- keywords="CDS, personalize",
- uid=uid,
- language=ln,
- lastupdated=__lastupdated__)
+ mess ="Your are not registered into the system please try again"
+ act = "register"
+ title = "Register failure"
+
+ return page(title=title,
+ body=webaccount.perform_back(mess,act),
+ navtrail="""Your Account""" % (weburl, ln),
+ description="CDS Personalize, Main page",
+ keywords="CDS, personalize",
+ uid=uid,
+ language=ln,
+ lastupdated=__lastupdated__)
diff --git a/modules/websession/web/youraccount.py.wml b/modules/websession/web/youraccount.py.wml
index d3df669bb..2d15f764f 100644
--- a/modules/websession/web/youraccount.py.wml
+++ b/modules/websession/web/youraccount.py.wml
@@ -1,289 +1,314 @@
## $Id$
## CDSware User account information.
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## read config variables:
#include "config.wml"
#include "configbis.wml"
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
"""CDSware ACCOUNT HANDLING"""
__lastupdated__ = """<: print `date +"%d %b %Y %H:%M:%S %Z"`; :>"""
## fill config variables:
pylibdir = "/python"
import sys
sys.path.append('%s' % pylibdir)
from cdsware import webuser
from cdsware.config import weburl,cdsname,cdslang,supportemail
from cdsware.webpage import page
from cdsware import webaccount
from cdsware import webbasket
from cdsware import webalert
from cdsware import webuser
from cdsware.access_control_config import *
from mod_python import apache
import smtplib
def set(req, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/set")
data = webuser.getDataUid(req,uid)
email = data[0]
passw = data[1]
return page(title="Your Settings",
body=webaccount.perform_set(email,passw),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Your Settings",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def change(req,email=None,password=None,ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/change")
if webuser.checkemail(email):
change = webuser.updateDataUser(req,uid,email,password)
return display(req, ln)
else :
return display(req, ln)
def lost(req, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/lost")
return page(title="Login",
body=webaccount.perform_lost(),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def display(req, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/display")
if webuser.isGuestUser(uid):
return page(title="Your Account",
body=webaccount.perform_info(req),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
data = webuser.getDataUid(req,uid)
bask = webbasket.account_list_baskets(uid)
aler = webalert.account_list_alerts(uid)
sear = webalert.account_list_searches(uid)
return page(title="Your Account",
body=webaccount.perform_display_account(req,data,bask,aler,sear),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def send_email(req, p_email=None, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/send_email")
passw = webuser.givePassword(p_email)
if passw == -999:
eMsg = "The entered e-mail address doesn't exist in the database"
return page(title="Your Account",
body=webaccount.perform_emailMessage(eMsg),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
fromaddr = "From: %s" % supportemail
toaddrs = "To: " + p_email
to = toaddrs + "\n"
sub = "Subject: Credentials for %s\n\n" % cdsname
body = "Here are your user credentials for %s:\n\n" % cdsname
body += " username: %s\n password: %s\n\n" % (p_email, passw)
body += "You can login at %s/youraccount.py/login" % weburl
msg = to + sub + body
server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
try:
server.sendmail(fromaddr, toaddrs, msg)
except smtplib.SMTPRecipientsRefused,e:
eMsg = "The entered e-mail address is incorrect, please check that it is written correctly (e.g. johndoe@example.com)"
return page(title="Your Account",
body=webaccount.perform_emailMessage(eMsg),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
server.quit()
return page(title="Your Account",
body=webaccount.perform_emailSent(p_email),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def youradminactivities(req, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/youradminactivities")
return page(title="Your Administrative Activities",
body=webaccount.perform_youradminactivities(uid),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def delete(req, ln=cdslang):
uid = webuser.getUid(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/delete")
return page(title="Delete Account",
body=webaccount.perform_delete(),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def logout(req, ln=cdslang):
uid = webuser.logoutUser(req)
if uid == -1:
return webuser.page_not_authorized(req, "../youraccount.py/logout")
return page(title="Logout",
body=webaccount.perform_logout(req),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
def login(req, p_email=None, p_pw=None, action='login', referer='', ln=cdslang):
uid = webuser.getUid(req)
- if action =='login':
-
+ if action =='register':
+ return page(title="Register",
+ body=webaccount.create_register_page_box(referer),
+ navtrail="""Your Account""" % (weburl, ln),
+ description="CDS Personalize, Main page",
+ keywords="CDS, personalize",
+ uid=uid,
+ language=ln,
+ lastupdated=__lastupdated__)
+ elif action =='login':
if p_email==None:
return page(title="Login",
- body=webaccount.perform_ask(referer),
+ body=webaccount.create_login_page_box(referer),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
iden = webuser.loginUser(p_email,p_pw)
if len(iden)>0:
uid = webuser.update_Uid(req,p_email,p_pw)
uid2 = webuser.getUid(req)
if uid2 == -1:
webuser.logoutUser(req)
return webuser.page_not_authorized(req, "../youraccount.py/login?ln=%s" % ln, uid=uid)
# login successful!
if referer:
req.err_headers_out.add("Location", referer)
raise apache.SERVER_RETURN, apache.HTTP_MOVED_PERMANENTLY
else:
return display(req)
else:
if webuser.userNotExist(p_email,p_pw) or p_email=='' or p_email==' ':
mess ="Your are not logged into the system, because this user is unknown."
else:
mess ="Your are not logged into the system, because you have introduced a wrong password."
act = "login"
return page(title="Login",
body=webaccount.perform_back(mess,act),
navtrail="""Your Account""" % (weburl, ln),
description="CDS Personalize, Main page",
keywords="CDS, personalize",
uid=uid,
language=ln,
lastupdated=__lastupdated__)
+
+def register(req, p_email=None, p_pw=None, action='login', referer='', ln=cdslang):
+ uid = webuser.getUid(req)
+
+ if p_email==None:
+ return page(title="Register",
+ body=webaccount.create_register_page_box(referer),
+ navtrail="""Your Account""" % (weburl, ln),
+ description="CDS Personalize, Main page",
+ keywords="CDS, personalize",
+ uid=uid,
+ language=ln,
+ lastupdated=__lastupdated__)
+
+ mess=""
+ act=""
+ ruid=webuser.registerUser(req,p_email,p_pw)
+ if ruid==1:
+ uid=webuser.update_Uid(req,p_email,p_pw)
+ mess = "Your account has been successfully created."
+ title = "Account created"
+ if CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT == 1:
+ mess += " An email has been sent to the given address with the account information."
+ if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 1:
+ mess += " A second email will be sent when the account has been activated and can be used."
+ else:
+ mess += """ To continue to your account, press here""" % (weburl, ln)
+ elif ruid ==-1 :
+ mess ="The user already exists in the database, please try again"
+ act = "register"
+ title = "Register failure"
else:
- mess=""
- act=""
- ruid=webuser.registerUser(req,p_email,p_pw)
- if ruid==1:
- uid=webuser.update_Uid(req,p_email,p_pw)
- mess = "Your account has been successfully created."
- if CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT == 1:
- mess += " An email has been sent to the given address with the account information."
- if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 1:
- mess += " A second email will be sent when the account has been activated and can be used."
- else:
- mess += """ To continue to your account, press here""" % (weburl, ln)
- elif ruid ==-1 :
- mess ="The user already exists in the database, please try again"
- act = "login"
- else:
- mess ="Your are not registered into the system please try again"
- act = "login"
- return page(title="Register failure",
- body=webaccount.perform_back(mess,act),
- navtrail="""Your Account""" % (weburl, ln),
- description="CDS Personalize, Main page",
- keywords="CDS, personalize",
- uid=uid,
- language=ln,
- lastupdated=__lastupdated__)
+ mess ="Your are not registered into the system please try again"
+ act = "register"
+ title = "Register failure"
+
+ return page(title=title,
+ body=webaccount.perform_back(mess,act),
+ navtrail="""Your Account""" % (weburl, ln),
+ description="CDS Personalize, Main page",
+ keywords="CDS, personalize",
+ uid=uid,
+ language=ln,
+ lastupdated=__lastupdated__)