*** empty log message ***
This commit is contained in:
219
venice-data/scripts/login.js
Normal file
219
venice-data/scripts/login.js
Normal file
@@ -0,0 +1,219 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importClass(Packages.com.silverwrist.dynamo.UserInfoNamespace);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.mail);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.frame);
|
||||
importPackage(Packages.com.silverwrist.venice.session);
|
||||
|
||||
req = bsf.lookupBean("request"); // get request
|
||||
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||
target = rhelp.getParameterString("tgt"); // get the target for this operation
|
||||
if (target==null)
|
||||
target = "top.js.vs";
|
||||
vlib.setOnError(req,target);
|
||||
|
||||
session = rhelp.getSession(); // get the session
|
||||
user = vlib.getUser(session);
|
||||
if (!(user.isAnonymous())) // user already logged in, just bounce back to where we came from
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",target));
|
||||
|
||||
// Load the login dialog.
|
||||
loader = cast.queryDialogLoader(req);
|
||||
dlg = loader.loadDialogResource("login.dlg.xml");
|
||||
|
||||
if (rhelp.isVerb("GET"))
|
||||
{ // just display the dialog and return
|
||||
dlg.setValue("tgt",target);
|
||||
vlib.setLocation(req,target);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end if
|
||||
|
||||
// everything that follows is for a POST operation
|
||||
op = dlg.getClickedButton(req) + "";
|
||||
if (op=="cancel") // user cancelled login - bounce back to the target
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",target));
|
||||
|
||||
dlg.load(req); // load dialog contents
|
||||
if (op=="reminder")
|
||||
{ // generate a password reminder
|
||||
errmsg = null;
|
||||
user = vlib.lookupUser(req,dlg.getValue("user"));
|
||||
if (user!=null)
|
||||
{ // user found...
|
||||
if (user.isAnonymous()) // can't do this for the Anonymous_Honyak account
|
||||
errmsg = "This account cannot be explicitly logged into. Please try again.";
|
||||
else
|
||||
{ // get the user's password reminder
|
||||
reminder_msg = PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,
|
||||
"password.reminder");
|
||||
if (reminder_msg==null)
|
||||
reminder_msg = "";
|
||||
|
||||
// generate and set authentication for the password recovery system
|
||||
auth = vlib.randomRecoveryAuth() + "." + dynamo.currentTimeMillis();
|
||||
user.setAuthenticationData(user,VeniceNamespaces.SESSION_CONTROL_NAMESPACE,"password.recovery","",auth);
|
||||
|
||||
// create and send the reminder E-mail message
|
||||
mailprov = cast.queryMailMessageProvider(req);
|
||||
msg = mailprov.createSystemMessage(req);
|
||||
msg.addRecipient(MailMessage.RECIP_TO,user.getEMailAddress());
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
msg.setSubject(globals.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,
|
||||
"reminder.message.title").toString());
|
||||
blocks = vcast.getGlobalBlocksStore(req);
|
||||
msg.setText(blocks.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,"reminder.message").toString());
|
||||
msg.setVariable("username",user.getName());
|
||||
msg.setVariable("reminder",reminder_msg);
|
||||
msg.setVariable("uid",cast.toIntegerObject(user.getUID()));
|
||||
msg.setVariable("auth",auth);
|
||||
msg.send();
|
||||
|
||||
// set the error message and prepare the dialog for reset
|
||||
errmsg = "Password reminder has been sent to the E-mail address for user '" + user.getName() + "'.";
|
||||
dlg.setValue("pass",null);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if
|
||||
else // user not found - bounce back with an error message
|
||||
errmsg = "The user account you have specified does not exist. Please try again.";
|
||||
|
||||
if (errmsg!=null)
|
||||
{ // set the error message and bounce back the dialog
|
||||
dlg.setErrorMessage(errmsg);
|
||||
dlg.setValue("user",null);
|
||||
dlg.setValue("pass",null);
|
||||
vlib.setLocation(req,target);
|
||||
dynamo.scriptOutput(new FrameDialog(dlg));
|
||||
|
||||
} // end if
|
||||
else // this ain't right
|
||||
dynamo.scriptOutput(new ErrorBox("Internal Error","Unknown outcome from password reminder",
|
||||
"SERVLET",target));
|
||||
|
||||
} // end if
|
||||
else if (op=="login")
|
||||
{ // attempt to log the user in!
|
||||
errmsg = null;
|
||||
new_user = vlib.lookupUser(req,dlg.getValue("user"));
|
||||
if (new_user!=null)
|
||||
{ // the user is present - we can do this
|
||||
if (new_user.isAnonymous())
|
||||
{ // can't log in as Anonymous_Honyak, foo!
|
||||
errmsg = "This account cannot be explicitly logged into. Please try again.";
|
||||
audit.write(req,new_user,VeniceNamespaces.USER_EVENT_NAMESPACE,"login.fail","Anonymous user");
|
||||
dlg.setValue("user",null);
|
||||
dlg.setValue("pass",null);
|
||||
|
||||
} // end if
|
||||
else if (new_user.isLocked())
|
||||
{ // account locked out - sorry!
|
||||
errmsg = "This account has been locked out. Please contact the system administrator for assistance.";
|
||||
audit.write(req,new_user,VeniceNamespaces.USER_EVENT_NAMESPACE,"login.fail","Locked Account");
|
||||
dlg.setValue("pass",null);
|
||||
|
||||
} // end else if
|
||||
else
|
||||
{ // OK, we can try to authenticate with this account!
|
||||
if (new_user.authenticate(UserInfoNamespace.NAMESPACE,UserInfoNamespace.AUTH_DEFAULT,"",
|
||||
dlg.getValue("pass")))
|
||||
{ // authenticated OK - set user into session
|
||||
logger.debug("User \"" + new_user.getName() + "\" logged in successfully");
|
||||
session.setObject(SessionInfoParams.NAMESPACE,SessionInfoParams.ATTR_USER,new_user);
|
||||
audit.write(req,new_user,VeniceNamespaces.USER_EVENT_NAMESPACE,"login.ok");
|
||||
new_user.setLastAccessDate(new_user,new java.util.Date());
|
||||
|
||||
// Now set up this user's default objects.
|
||||
dynamo.exec("/util/setup_user.js");
|
||||
|
||||
if (cast.toBoolean(dlg.getValue("saveme")))
|
||||
{ // user wants a cookie - generate one
|
||||
source = vlib.randomString(32);
|
||||
auth = vlib.randomString(32);
|
||||
try
|
||||
{ // set the user authentication data
|
||||
new_user.setAuthenticationData(new_user,VeniceNamespaces.SESSION_CONTROL_NAMESPACE,"cookie",
|
||||
source,auth);
|
||||
|
||||
// save the persistent cookie value
|
||||
cval = "VQAT2:" + new_user.getUID() + ":" + source + ":" + auth;
|
||||
cctrl = cast.queryCookieControl(req);
|
||||
cctrl.putPersistentCookie(venice_session.loginCookieName,cval,venice_session.loginCookieAge);
|
||||
|
||||
// set the cookie authentication source so we can delete the auth info later at logout
|
||||
session.setObject(SessionInfoParams.NAMESPACE,SessionInfoParams.ATTR_COOKIE_AUTH_SOURCE,source);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // ignore exception here
|
||||
logger.warn("cookie setup process threw exception",e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
// Has the user verified their E-mail address yet? If not, bounce them there.
|
||||
if (PropertyUtils.hasProperty(new_user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"confirmation.number"))
|
||||
dynamo.scriptReturn(new Redirect("SERVLET","verify_email.js.vs?tgt="
|
||||
+ stringutils.encodeURL(target)));
|
||||
else
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",target));
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // the password is wrong - please try again
|
||||
errmsg = "The password specified for this user account is incorrect. Please try again.";
|
||||
audit.write(req,new_user,VeniceNamespaces.USER_EVENT_NAMESPACE,"login.fail","Bad password");
|
||||
dlg.setValue("pass",null);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // user not found - bounce back with an error message
|
||||
errmsg = "The user account you have specified does not exist. Please try again.";
|
||||
audit.write(req,null,VeniceNamespaces.USER_EVENT_NAMESPACE,"login.fail","Bad username",
|
||||
dlg.getValue("user"));
|
||||
dlg.setValue("user",null);
|
||||
dlg.setValue("pass",null);
|
||||
|
||||
} // end else
|
||||
|
||||
if (errmsg!=null)
|
||||
{ // set the error message and bounce back the dialog
|
||||
dlg.setErrorMessage(errmsg);
|
||||
vlib.setLocation(req,target);
|
||||
dynamo.scriptOutput(new FrameDialog(dlg));
|
||||
|
||||
} // end if
|
||||
else
|
||||
dynamo.scriptOutput(new ErrorBox("Internal Error","Unknown outcome from login","SERVLET",target));
|
||||
|
||||
} // end else if
|
||||
else
|
||||
{ // unknown command button pressed!
|
||||
logger.error("no known button click on POST to login.js");
|
||||
dynamo.scriptOutput(new ErrorBox("Internal Error","Unknown command button pressed","SERVLET",target));
|
||||
|
||||
} // end else
|
||||
48
venice-data/scripts/logout.js
Normal file
48
venice-data/scripts/logout.js
Normal file
@@ -0,0 +1,48 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importPackage(Packages.com.silverwrist.venice.session);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
|
||||
req = bsf.lookupBean("request"); // get request
|
||||
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||
target = rhelp.getParameterString("tgt"); // get the target for this operation
|
||||
if (target==null)
|
||||
target = "top.js.vs";
|
||||
vlib.setOnError(req,target);
|
||||
|
||||
session = rhelp.getSession(); // get the session
|
||||
user = vlib.getUser(session);
|
||||
if (!(user.isAnonymous()))
|
||||
{ // dump the login cookie, if we have it set
|
||||
cctrl = cast.queryCookieControl(req);
|
||||
if (cctrl.isCookiePresent(venice_session.loginCookieName))
|
||||
{ // get rid of the cookie and its associated cookie authentication, lest it clutter the database
|
||||
source = session.getObject(SessionInfoParams.NAMESPACE,SessionInfoParams.ATTR_COOKIE_AUTH_SOURCE);
|
||||
user.clearAuthenticationData(user,VeniceNamespaces.SESSION_CONTROL_NAMESPACE,"cookie",source);
|
||||
cctrl.deleteCookie(venice_session.loginCookieName);
|
||||
|
||||
} // end if
|
||||
|
||||
session.invalidate(); // this dumps the entire session
|
||||
|
||||
target = "top.js.vs"; // go back to the "top" display
|
||||
|
||||
} // end if
|
||||
|
||||
dynamo.scriptOutput(new Redirect("SERVLET",target)); // bounce back to the target
|
||||
55
venice-data/scripts/new_account.js
Normal file
55
venice-data/scripts/new_account.js
Normal file
@@ -0,0 +1,55 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.content);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
req_help = bsf.lookupBean("request_help");
|
||||
target = req_help.getParameterString("tgt");
|
||||
if (target==null)
|
||||
target = "top.js.vs";
|
||||
vlib.setOnError(req,target);
|
||||
|
||||
// Check the user account.
|
||||
user = vlib.getUser(req);
|
||||
if (!(user.isAnonymous())) // user already logged in, must log out first
|
||||
dynamo.scriptReturn(new ErrorBox(null,"You cannot create a new account while logged in on an existing one. "
|
||||
+ "You must log out first.",target));
|
||||
|
||||
// Get the user agreement title and subtitle.
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
s_title = globals.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"user.agreement.title");
|
||||
s_subtitle = PropertyUtils.getPropertyNoErr(globals,VeniceNamespaces.CONTENT_LAF_NAMESPACE,
|
||||
"user.agreement.subtitle");
|
||||
|
||||
// Get the content block provider.
|
||||
csupp = vcast.queryContentBlockProvider(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
"venice-content"));
|
||||
|
||||
// Construct the "User Agreement" page.
|
||||
vlib.setDisplayLogin(req,false);
|
||||
rc = new StdTextMessage(req);
|
||||
rc.title = s_title;
|
||||
if (s_subtitle!=null)
|
||||
rc.subtitle = s_subtitle;
|
||||
rc.content = csupp.getContentBlock("user.agreement");
|
||||
rc.addButton("SERVLET","new_account_2.js.vs?tgt=" + stringutils.encodeURL(target),"i.accept");
|
||||
rc.addButton("SERVLET",target,"i.decline");
|
||||
dynamo.scriptOutput(rc);
|
||||
173
venice-data/scripts/new_account_2.js
Normal file
173
venice-data/scripts/new_account_2.js
Normal file
@@ -0,0 +1,173 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(java.lang);
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importClass(Packages.com.silverwrist.dynamo.UserInfoNamespace);
|
||||
importPackage(Packages.com.silverwrist.dynamo.dialog);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.mail);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.frame);
|
||||
importPackage(Packages.com.silverwrist.venice.session);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
req_help = bsf.lookupBean("request_help");
|
||||
target = req_help.getParameterString("tgt");
|
||||
if (target==null)
|
||||
target = "top.js.vs";
|
||||
vlib.setOnError(req,target);
|
||||
|
||||
// Check the user account.
|
||||
user = vlib.getUser(req);
|
||||
if (!(user.isAnonymous())) // user already logged in, must log out first
|
||||
dynamo.scriptReturn(new ErrorBox(null,"You cannot create a new account while logged in on an existing one. "
|
||||
+ "You must log out first.",target));
|
||||
|
||||
// Load the new account dialog.
|
||||
loader = cast.queryDialogLoader(req);
|
||||
dlg = loader.loadDialogResource("new_account.dlg.xml");
|
||||
|
||||
if (req_help.isVerb("GET"))
|
||||
{ // fill in the dialog for a GET and return it
|
||||
dlg.setValue("tgt",target);
|
||||
vlib.setLocation(req,target);
|
||||
vlib.setDisplayLogin(req,false);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end if
|
||||
|
||||
// everything that follows is for a POST operation
|
||||
op = dlg.getClickedButton(req) + "";
|
||||
if (op=="cancel") // user cancelled login - bounce back to the target
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",target));
|
||||
|
||||
dlg.load(req); // load dialog contents
|
||||
try
|
||||
{ // validate the dialog contents
|
||||
dlg.validate(req);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // the validation failed - throw an error message
|
||||
logger.error("Dialog validation failed",e);
|
||||
dlg.setErrorMessage(dynamo.exceptionMessage(e) + " Please try again.");
|
||||
vlib.setLocation(req,target);
|
||||
vlib.setDisplayLogin(req,false);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end catch
|
||||
|
||||
if (op=="create")
|
||||
{ // check the two passwords
|
||||
pass1 = dlg.getValue("pass1");
|
||||
pass2 = dlg.getValue("pass2");
|
||||
if (!(pass1.equals(pass2)))
|
||||
{ // the two passwords don't match -
|
||||
dlg.setErrorMessage("The passwords do not match. Please try again.");
|
||||
vlib.setLocation(req,target);
|
||||
vlib.setDisplayLogin(req,false);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end if
|
||||
|
||||
// get the profile information to a local object store
|
||||
temp_profile = new MemoryObjectStore("login profile");
|
||||
PropertyUtils.setIfNonNull(temp_profile,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.prefix",
|
||||
dlg.getValue("prefix"));
|
||||
temp_profile.setObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.given",dlg.getValue("first"));
|
||||
s = dlg.getValue("mid");
|
||||
if (s!=null)
|
||||
temp_profile.setObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.mi",
|
||||
new Character(s.toString().charAt(0)));
|
||||
temp_profile.setObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.family",dlg.getValue("last"));
|
||||
PropertyUtils.setIfNonNull(temp_profile,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.suffix",
|
||||
dlg.getValue("suffix"));
|
||||
temp_profile.setObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"locality",dlg.getValue("loc"));
|
||||
temp_profile.setObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"region",dlg.getValue("reg"));
|
||||
temp_profile.setObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"postal.code",dlg.getValue("pcode"));
|
||||
temp_profile.setObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"country",dlg.getValue("country"));
|
||||
PropertyUtils.setIfNonNull(temp_profile,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"password.reminder",
|
||||
dlg.getValue("remind"));
|
||||
|
||||
// Create the DynamoUser object.
|
||||
umgmt = cast.queryUserManagement(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"users"));
|
||||
new_user = umgmt.createUser(dlg.getValue("user"),dlg.getValue("email"));
|
||||
|
||||
// Set the initial authentication info.
|
||||
new_user.setAuthenticationData(new_user,UserInfoNamespace.NAMESPACE,UserInfoNamespace.AUTH_DEFAULT,"",pass1);
|
||||
|
||||
// Copy all default properties to this user.
|
||||
udpns = vcast.queryUserDefaultPropertyNamespace(req);
|
||||
umgmt.loadUserDefaults(new_user,udpns.getDefaultPropertyNamespaces());
|
||||
|
||||
// Set the "profile last updated" date for the user.
|
||||
temp_profile.setObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"last.update",new_user.getCreationDate());
|
||||
|
||||
// Copy in the user properties.
|
||||
if (!(PropertyUtils.copyPropertyNamespace(new_user,temp_profile,new_user,
|
||||
VeniceNamespaces.USER_PROFILE_NAMESPACE)))
|
||||
dynamo.scriptReturn(new ErrorBox("Internal Error","Unable to copy profile to new user.",target));
|
||||
if (!(PropertyUtils.copyPropertyNamespace(new_user,temp_profile,new_user,
|
||||
VeniceNamespaces.USER_SETTINGS_NAMESPACE)))
|
||||
dynamo.scriptReturn(new ErrorBox("Internal Error","Unable to copy settings to new user.",target));
|
||||
|
||||
// Add this user to the "all users" group.
|
||||
srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
"srm"));
|
||||
srm.getAllUsersGroup().addMember(new_user);
|
||||
|
||||
// Write an audit message indicating the new user was created.
|
||||
audit.write(req,new_user,VeniceNamespaces.USER_EVENT_NAMESPACE,"user.created");
|
||||
|
||||
// Generate an E-mail confirmation number and add it to the user properties.
|
||||
confnum = vlib.randomConfirmationNumber();
|
||||
new_user.setObject(new_user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"confirmation.number",
|
||||
cast.toIntegerObject(confnum));
|
||||
|
||||
// At this point, the user is completely set up, so act like we're logging in as that user.
|
||||
req_help.getSession().setObject(SessionInfoParams.NAMESPACE,SessionInfoParams.ATTR_USER,new_user);
|
||||
new_user.setLastAccessDate(new_user,new java.util.Date());
|
||||
dynamo.exec("/util/setup_user.js");
|
||||
|
||||
// Generate and send an E-mail message to the user with the confirmation number.
|
||||
mailprov = cast.queryMailMessageProvider(req);
|
||||
msg = mailprov.createSystemMessage(req);
|
||||
msg.addRecipient(MailMessage.RECIP_TO,new_user.getEMailAddress());
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
msg.setSubject(globals.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,
|
||||
"confirm.message.title").toString());
|
||||
blocks = vcast.getGlobalBlocksStore(req);
|
||||
msg.setText(blocks.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,"confirm.message").toString());
|
||||
msg.setVariable("username",new_user.getName());
|
||||
msg.setVariable("confnum",cast.toIntegerObject(confnum));
|
||||
msg.send();
|
||||
|
||||
// Write an audit message.
|
||||
audit.write(req,new_user,VeniceNamespaces.USER_EVENT_NAMESPACE,"send.confirm.email",
|
||||
new_user.getEMailAddress());
|
||||
|
||||
// Now bounce us to the "verification" dialog.
|
||||
dynamo.scriptOutput(new Redirect("SERVLET","verify_email.js.vs?tgt=" + stringutils.encodeURL(target)));
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // unknown command button pressed!
|
||||
logger.error("no known button click on POST to new_account_2.js");
|
||||
dynamo.scriptOutput(new ErrorBox("Internal Error","Unknown command button pressed","SERVLET",target));
|
||||
|
||||
} // end else
|
||||
274
venice-data/scripts/profile.js
Normal file
274
venice-data/scripts/profile.js
Normal file
@@ -0,0 +1,274 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(java.lang);
|
||||
importPackage(Packages.com.silverwrist.util);
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importClass(Packages.com.silverwrist.dynamo.UserInfoNamespace);
|
||||
importPackage(Packages.com.silverwrist.dynamo.dialog);
|
||||
importPackage(Packages.com.silverwrist.dynamo.except);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.mail);
|
||||
importPackage(Packages.com.silverwrist.dynamo.security);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.frame);
|
||||
importPackage(Packages.com.silverwrist.venice.session);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
req_help = bsf.lookupBean("request_help");
|
||||
target = req_help.getParameterString("tgt");
|
||||
if (target==null)
|
||||
target = "top.js.vs";
|
||||
vlib.setOnError(req,target);
|
||||
|
||||
// Check the user account.
|
||||
user = vlib.getUser(req);
|
||||
if (user.isAnonymous())
|
||||
{ // user not logged in, must log in first - so bounce us to the login dialog
|
||||
new_target = "profile.js.vs?tgt=" + stringutils.encodeURL(target);
|
||||
dynamo.scriptReturn(new Redirect("SERVLET","login.js.vs?tgt=" + stringutils.encodeURL(new_target)));
|
||||
|
||||
} // end if
|
||||
|
||||
// Create the profile dialog.
|
||||
loader = cast.queryDialogLoader(req);
|
||||
dlg = loader.loadDialogResource("user_profile.dlg.xml");
|
||||
|
||||
if (req_help.isVerb("GET"))
|
||||
{ // Get the privacy settings and admin flags.
|
||||
priv = cast.toOptionSet(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"privacy"));
|
||||
admin_flags = cast.toOptionSet(user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"admin.flags"));
|
||||
|
||||
// Fill in dialog and return it for a GET.
|
||||
dlg.setValue("tgt",target);
|
||||
// N.B.: do not set pass1, pass2, or remind
|
||||
dlg.setValue("prefix",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"name.prefix"));
|
||||
dlg.setValue("first",user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.given"));
|
||||
dlg.setValue("mid",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"name.mi"));
|
||||
dlg.setValue("last",user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.family"));
|
||||
dlg.setValue("suffix",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"name.suffix"));
|
||||
dlg.setValue("company",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"company.name"));
|
||||
dlg.setValue("addr1",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"address.1"));
|
||||
dlg.setValue("addr2",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"address.2"));
|
||||
dlg.setValue("pvt_addr",cast.booleanObject(priv.get(0)));
|
||||
dlg.setValue("loc",user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"locality"));
|
||||
dlg.setValue("reg",user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"region"));
|
||||
dlg.setValue("pcode",user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"postal.code"));
|
||||
dlg.setValue("country",user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"country"));
|
||||
dlg.setValue("phone",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"phone.voice"));
|
||||
dlg.setValue("pvt_phone",cast.booleanObject(priv.get(1)));
|
||||
dlg.setValue("mobile",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"phone.mobile"));
|
||||
dlg.setValue("pvt_mobile",cast.booleanObject(priv.get(2)));
|
||||
dlg.setValue("fax",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"phone.fax"));
|
||||
dlg.setValue("pvt_fax",cast.booleanObject(priv.get(3)));
|
||||
dlg.setValue("email",user.getEMailAddress());
|
||||
dlg.setValue("pvt_email",cast.booleanObject(priv.get(4)));
|
||||
dlg.setValue("url",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"url.homepage"));
|
||||
dlg.setValue("descr",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"description"));
|
||||
dlg.setValue("photo",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"url.photo"));
|
||||
if (dlg.getValue("photo")==null)
|
||||
{ // fill in the "no photo" URL
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
url = globals.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"user.nophoto.url");
|
||||
urltype = globals.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"user.nophoto.url.type");
|
||||
rewriter = cast.queryURLRewriter(req);
|
||||
dlg.setValue("photo",rewriter.rewriteURL(urltype,url));
|
||||
|
||||
} // end if
|
||||
|
||||
if (admin_flags.get(0))
|
||||
dlg.setEnabled("photo",false);
|
||||
|
||||
dlg.setValue("no_mass_mail",cast.booleanObject(user.isNoSpam()));
|
||||
dlg.setValue("locale",user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"locale"));
|
||||
dlg.setValue("tz",user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"timezone"));
|
||||
|
||||
// prepare the dialog and return it
|
||||
dlg.setRenderParam("rtgt",stringutils.encodeURL(target));
|
||||
vlib.setLocation(req,target);
|
||||
vlib.setDisplayLogin(req,false);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end if
|
||||
|
||||
// everything that follows here is for a POST operation
|
||||
op = dlg.getClickedButton(req) + "";
|
||||
if (op=="cancel") // user cancelled login - bounce back to the target
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",target));
|
||||
|
||||
dlg.load(req); // load dialog contents
|
||||
try
|
||||
{ // validate the dialog contents
|
||||
dlg.validate(req);
|
||||
|
||||
// if a new password has been specified, make sure it was properly specified twice
|
||||
pass1 = dlg.getValue("pass1");
|
||||
pass2 = dlg.getValue("pass2");
|
||||
if (stringutils.isNotEmpty(pass1))
|
||||
{ // dest password equality
|
||||
if (stringutils.isEmpty(pass2) || !(pass1.equals(pass2)))
|
||||
throw new DynamoException("The specified passwords do not match.");
|
||||
|
||||
} // end if
|
||||
else if (stringutils.isNotEmpty(pass2))
|
||||
throw new DynamoException("The specified passwords do not match.");
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // the validation failed - throw an error message
|
||||
logger.error("Dialog validation failed",e);
|
||||
dlg.setErrorMessage(dynamo.exceptionMessage(e) + " Please try again.");
|
||||
|
||||
// have to re-prep the user photo
|
||||
dlg.setValue("photo",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"url.photo"));
|
||||
if (dlg.getValue("photo")==null)
|
||||
{ // fill in the "no photo" URL
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
url = globals.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"user.nophoto.url");
|
||||
urltype = globals.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"user.nophoto.url.type");
|
||||
rewriter = cast.queryURLRewriter(req);
|
||||
dlg.setValue("photo",rewriter.rewriteURL(urltype,url));
|
||||
|
||||
} // end if
|
||||
|
||||
if (admin_flags.get(0))
|
||||
dlg.setEnabled("photo",false);
|
||||
|
||||
dlg.setRenderParam("rtgt",stringutils.encodeURL(target));
|
||||
vlib.setLocation(req,target);
|
||||
vlib.setDisplayLogin(req,false);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end catch
|
||||
|
||||
if (op=="update")
|
||||
{ // get the user privacy settings
|
||||
priv = cast.toOptionSet(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"privacy"));
|
||||
|
||||
// poke in all the updates for the user!
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.prefix",
|
||||
dlg.getValue("prefix"));
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.given",dlg.getValue("first"));
|
||||
s = dlg.getValue("mid");
|
||||
if (s!=null)
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.mi",
|
||||
new Character(s.toString().charAt(0)));
|
||||
else
|
||||
user.removeObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.mi");
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.family",dlg.getValue("last"));
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.suffix",
|
||||
dlg.getValue("suffix"));
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"company.name",
|
||||
dlg.getValue("company"));
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"address.1",
|
||||
dlg.getValue("addr1"));
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"address.2",
|
||||
dlg.getValue("addr2"));
|
||||
priv.set(0,cast.toBoolean(dlg.getValue("pvt_addr")));
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"locality",dlg.getValue("loc"));
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"region",dlg.getValue("reg"));
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"postal.code",dlg.getValue("pcode"));
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"country",dlg.getValue("country"));
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"phone.voice",
|
||||
dlg.getValue("phone"));
|
||||
priv.set(1,cast.toBoolean(dlg.getValue("pvt_phone")));
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"phone.mobile",
|
||||
dlg.getValue("mobile"));
|
||||
priv.set(2,cast.toBoolean(dlg.getValue("pvt_mobile")));
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"phone.fax",
|
||||
dlg.getValue("fax"));
|
||||
priv.set(3,cast.toBoolean(dlg.getValue("pvt_fax")));
|
||||
reverify = user.setEMailAddress(user,dlg.getValue("email"));
|
||||
priv.set(4,cast.toBoolean(dlg.getValue("pvt_email")));
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"url.homepage",
|
||||
dlg.getValue("url"));
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"description",
|
||||
dlg.getValue("descr"));
|
||||
user.setNoSpam(user,cast.toBoolean(dlg.getValue("no_mass_mail")));
|
||||
user.setObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"locale",dlg.getValue("locale"));
|
||||
user.setObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"timezone",dlg.getValue("tz"));
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"privacy",priv);
|
||||
|
||||
// Set the "profile last updated" date for the user.
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"last.update",dynamo.currentDate());
|
||||
|
||||
// Reset the password.
|
||||
pass = dlg.getValue("pass1");
|
||||
if (stringutils.isNotEmpty(pass1))
|
||||
{ // set the password and reminder
|
||||
user.setAuthenticationData(user,UserInfoNamespace.NAMESPACE,UserInfoNamespace.AUTH_DEFAULT,"",pass);
|
||||
PropertyUtils.setOrRemove(user,user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"password.reminder",
|
||||
dlg.getValue("remind"));
|
||||
|
||||
} // end if
|
||||
|
||||
if (!reverify) // all done - we can go back where we came from
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",target));
|
||||
|
||||
// The user might not need to re-verify - test this
|
||||
srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
"srm"));
|
||||
if (srm.getGlobalAcl().testPermission(user,Namespaces.DYNAMO_USER_INFO_NAMESPACE,"bypass.email.verify"))
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",target));
|
||||
|
||||
// User needs to be re-verified - generate a new confirmation number
|
||||
confnum = vlib.randomConfirmationNumber();
|
||||
user.setObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"confirmation.number",
|
||||
cast.toIntegerObject(confnum));
|
||||
|
||||
// remove us from Verified Users for the nonce
|
||||
srm.getVerifiedUsersGroup().removeMember(user);
|
||||
|
||||
// Generate and send an E-mail message to the user with the confirmation number.
|
||||
mailprov = cast.queryMailMessageProvider(req);
|
||||
msg = mailprov.createSystemMessage(req);
|
||||
msg.addRecipient(MailMessage.RECIP_TO,new_user.getEMailAddress());
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
msg.setSubject(globals.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,
|
||||
"confirm.message.title").toString());
|
||||
blocks = vcast.getGlobalBlocksStore(req);
|
||||
msg.setText(blocks.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,"confirm.message").toString());
|
||||
msg.setVariable("username",new_user.getName());
|
||||
msg.setVariable("confnum",cast.toIntegerObject(confnum));
|
||||
msg.send();
|
||||
|
||||
// Write an audit message.
|
||||
audit.write(req,user,VeniceNamespaces.USER_EVENT_NAMESPACE,"send.confirm.email",user.getEMailAddress());
|
||||
|
||||
// Now bounce us to the "verification" dialog.
|
||||
dynamo.scriptOutput(new Redirect("SERVLET","verify_email.js.vs?tgt=" + stringutils.encodeURL(target)));
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // unknown command button pressed!
|
||||
logger.error("no known button click on POST to profile.js");
|
||||
dynamo.scriptOutput(new ErrorBox("Internal Error","Unknown command button pressed","SERVLET",target));
|
||||
|
||||
} // end else
|
||||
109
venice-data/scripts/profile_photo.js
Normal file
109
venice-data/scripts/profile_photo.js
Normal file
@@ -0,0 +1,109 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(Packages.com.silverwrist.util);
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importClass(Packages.com.silverwrist.dynamo.db.ImageStore);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.content);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
req_help = bsf.lookupBean("request_help");
|
||||
target = req_help.getParameterString("tgt");
|
||||
if (target==null)
|
||||
target = "top.js.vs";
|
||||
on_error = "profile.js.vs?tgt=" + stringutils.encodeURL(target);
|
||||
vlib.setOnError(req,on_error);
|
||||
|
||||
// Check the user account.
|
||||
user = vlib.getUser(req);
|
||||
if (user.isAnonymous())
|
||||
{ // user not logged in, must log in first - so bounce us to the login dialog
|
||||
new_target = "profile_photo.js.vs?tgt=" + stringutils.encodeURL(target);
|
||||
dynamo.scriptReturn(new Redirect("SERVLET","login.js.vs?tgt=" + stringutils.encodeURL(new_target)));
|
||||
|
||||
} // end if
|
||||
|
||||
// Make sure they can actually edit their own photo.
|
||||
admin_flags = cast.toOptionSet(user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"admin.flags"));
|
||||
if (admin_flags.get(0))
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",on_error));
|
||||
|
||||
if (req_help.isVerb("GET"))
|
||||
{ // on GET, display the form
|
||||
view = new VelocityView("Set User Photo","user/user_photo.vm");
|
||||
view.setParameter("target",target);
|
||||
dynamo.scriptReturn(view);
|
||||
|
||||
} // end if
|
||||
|
||||
// everything from this point on is a POST operation
|
||||
if (req_help.isImageButtonClicked("cancel"))
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",on_error));
|
||||
|
||||
// get the image provider object
|
||||
imgprov = cast.queryImageStore(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"images"));
|
||||
|
||||
// figure out which image ID we have
|
||||
imgid = imgprov.findImageID(VeniceNamespaces.USER_PROFILE_NAMESPACE,"user.photo",user);
|
||||
|
||||
selector = req_help.getParameterString("selector") + "";
|
||||
if (selector=="none")
|
||||
{ // take out the image property and the image
|
||||
if (PropertyUtils.hasProperty(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"url.photo"))
|
||||
user.removeObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"url.photo");
|
||||
if (imgid!=-1)
|
||||
imgprov.deleteImage(user,imgid);
|
||||
|
||||
} // end if
|
||||
else if (selector=="set")
|
||||
{ // set the image URL directly, delete the image
|
||||
s = req_help.getParameterString("url");
|
||||
if (stringutils.isEmpty(s))
|
||||
dynamo.scriptReturn(new ErrorBox(null,"No photo URL specified.",on_error));
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"url.photo",s);
|
||||
if (imgid!=-1)
|
||||
imgprov.deleteImage(user,imgid);
|
||||
|
||||
} // end else if
|
||||
else if (selector=="upload")
|
||||
{ // take the uploaded image, reformat it, and save it off, then set the image URL
|
||||
input_di = req_help.getDataItem("image");
|
||||
if (input_di==null)
|
||||
dynamo.scriptReturn(new ErrorBox(null,"No uploaded photo specified.",on_error));
|
||||
mtype = input_di.getMimeType();
|
||||
if (!(mtype.startsWith("image/")))
|
||||
dynamo.scriptReturn(new ErrorBox(null,"Uploaded data item is not an image.",on_error));
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
width = cast.toInteger(globals.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"user.photo.width"));
|
||||
height = cast.toInteger(globals.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"user.photo.height"));
|
||||
di = imgprov.normalizeImage(input_di,width,height,"image/jpeg");
|
||||
if (imgid!=-1)
|
||||
imgprov.replaceImage(user,imgid,di);
|
||||
else
|
||||
imgid = imgprov.saveNewImage(VeniceNamespaces.USER_PROFILE_NAMESPACE,"user.photo",user,di);
|
||||
rewriter = cast.queryURLRewriter(req);
|
||||
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"url.photo",
|
||||
rewriter.rewriteURL("IMAGEDATA",imgid + ""));
|
||||
|
||||
} // end else if
|
||||
else // return a "No Content" and just leave the dialog box up
|
||||
dynamo.scriptReturn(new NoContent());
|
||||
|
||||
// All done - bounce back to the Profile dialog
|
||||
dynamo.scriptOutput(new Redirect("SERVLET",on_error));
|
||||
48
venice-data/scripts/quick_email.js
Normal file
48
venice-data/scripts/quick_email.js
Normal file
@@ -0,0 +1,48 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.mail);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importPackage(Packages.com.silverwrist.venice.content);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
req_help = bsf.lookupBean("request_help");
|
||||
me = vlib.getUser(req);
|
||||
|
||||
to_uid = req_help.getParameterInt("to_uid",-1);
|
||||
if (to_uid<=0)
|
||||
dynamo.scriptReturn(new ErrorBox(null,"Invalid user ID parameter."));
|
||||
|
||||
on_error = "top.js.vs";
|
||||
user = vlib.lookupUser(req,to_uid);
|
||||
if (user==null)
|
||||
dynamo.scriptReturn(new ErrorBox(null,"Invalid user ID parameter.",on_error));
|
||||
on_error = "user/" + user.getName();
|
||||
vlib.setOnError(req,on_error);
|
||||
|
||||
logger.debug("sending quick email message to " + user.getName());
|
||||
|
||||
// compose the E-mail message
|
||||
mailprov = cast.queryMailMessageProvider(req);
|
||||
msg = mailprov.createUserMessage(req,me);
|
||||
msg.addRecipient(MailMessage.RECIP_TO,user.getEMailAddress());
|
||||
msg.setSubject(req_help.getParameterString("subj"));
|
||||
msg.setText(req_help.getParameterString("pb"));
|
||||
msg.send();
|
||||
|
||||
// all done - bounce back to the user's profile.
|
||||
dynamo.scriptOutput(new Redirect("SERVLET","user/" + user.getName()));
|
||||
43
venice-data/scripts/top.js
Normal file
43
venice-data/scripts/top.js
Normal file
@@ -0,0 +1,43 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(java.util);
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importPackage(Packages.com.silverwrist.venice.frame);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
req_help = bsf.lookupBean("request_help");
|
||||
|
||||
// N.B. THIS IS ALL TEMPORARY
|
||||
|
||||
// Find the standard content supplier.
|
||||
tmp = req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-content");
|
||||
scs = vcast.queryContentBlockProvider(tmp);
|
||||
|
||||
// Get an instance of the content block representing the page title.
|
||||
cblk = scs.getContentBlock("content.header");
|
||||
cblk.setContentParameter("title","Content Title");
|
||||
cblk.setContentParameter("subtitle","Content Subtitle");
|
||||
|
||||
// Put together a list of objects to render in order.
|
||||
rc = new ArrayList();
|
||||
rc.add(cblk);
|
||||
rc.add("Temporary second return value");
|
||||
|
||||
// We're outta here.
|
||||
dynamo.scriptReturn(new TempFramedContent(rc));
|
||||
152
venice-data/scripts/verify_email.js
Normal file
152
venice-data/scripts/verify_email.js
Normal file
@@ -0,0 +1,152 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.mail);
|
||||
importPackage(Packages.com.silverwrist.dynamo.security);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
req_help = bsf.lookupBean("request_help");
|
||||
target = req_help.getParameterString("tgt");
|
||||
if (target==null)
|
||||
target = "top.js.vs";
|
||||
vlib.setOnError(req,target);
|
||||
|
||||
// Check the user account.
|
||||
user = vlib.getUser(req);
|
||||
if (user.isAnonymous())
|
||||
{ // user not logged in, must log in first - so bounce us to the login dialog
|
||||
new_target = "verify_email.js.vs?tgt=" + stringutils.encodeURL(target);
|
||||
dynamo.scriptReturn(new Redirect("SERVLET","login.js.vs?tgt=" + stringutils.encodeURL(new_target)));
|
||||
|
||||
} // end if
|
||||
|
||||
// If user is already verified, this is a no-op.
|
||||
if (!PropertyUtils.hasProperty(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"confirmation.number"))
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",target));
|
||||
confnum = cast.toInteger(user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"confirmation.number"));
|
||||
|
||||
// Load the verification dialog.
|
||||
loader = cast.queryDialogLoader(req);
|
||||
dlg = loader.loadDialogResource("verify.dlg.xml");
|
||||
|
||||
if (req_help.isVerb("GET"))
|
||||
{ // fill in the dialog for a GET and return it
|
||||
dlg.setValue("tgt",target);
|
||||
vlib.setLocation(req,target);
|
||||
vlib.setDisplayLogin(req,false);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end if
|
||||
|
||||
// Everything that follows is for a POST operation
|
||||
op = dlg.getClickedButton(req) + "";
|
||||
if (op=="cancel") // user cancelled verification - bounce us back to the target
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",target));
|
||||
else if (op=="send.again")
|
||||
{ // generate a new confirmation number before we re-send the message
|
||||
confnum = vlib.randomConfirmationNumber();
|
||||
user.setObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"confirmation.number",
|
||||
cast.toIntegerObject(confnum));
|
||||
|
||||
// send the verification E-mail message again
|
||||
mailprov = cast.queryMailMessageProvider(req);
|
||||
msg = mailprov.createSystemMessage(req);
|
||||
msg.addRecipient(MailMessage.RECIP_TO,user.getEMailAddress());
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
msg.setSubject(globals.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,
|
||||
"confirm.message.title").toString());
|
||||
blocks = vcast.getGlobalBlocksStore(req);
|
||||
msg.setText(blocks.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,"confirm.message").toString());
|
||||
msg.setVariable("username",user.getName());
|
||||
msg.setVariable("confnum",cast.toIntegerObject(confnum));
|
||||
msg.send();
|
||||
|
||||
// Record an audit message.
|
||||
audit.write(req,user,VeniceNamespaces.USER_EVENT_NAMESPACE,"resend.confirm.email",
|
||||
user.getEMailAddress());
|
||||
|
||||
// bounce us back to the dialog
|
||||
dlg.setErrorMessage("New confirmation message sent.");
|
||||
dlg.setValue("tgt",target);
|
||||
vlib.setLocation(req,target);
|
||||
vlib.setDisplayLogin(req,false);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end else if
|
||||
|
||||
dlg.load(req); // load dialog contents
|
||||
try
|
||||
{ // validate the dialog contents
|
||||
dlg.validate(req);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // the validation failed - throw an error message
|
||||
logger.error("Verify E-Mail dialog failed validation",e);
|
||||
dlg.setErrorMessage(dynamo.exceptionMessage(e) + " Please try again.");
|
||||
dlg.setValue("num",null);
|
||||
vlib.setLocation(req,target);
|
||||
vlib.setDisplayLogin(req,false);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end catch
|
||||
|
||||
if (op=="ok")
|
||||
{ // the button has been pressed - is the confirmation number correct?
|
||||
if (!(dlg.containsValue("num")))
|
||||
{ // no confirmation number entered!!!
|
||||
dlg.setErrorMessage("No confirmation number entered. Please try again.");
|
||||
vlib.setLocation(req,target);
|
||||
vlib.setDisplayLogin(req,false);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end if
|
||||
|
||||
new_num = cast.toInteger(dlg.getValue("num"));
|
||||
if (new_num!=confnum)
|
||||
{ // confirmation numbers don't match - bogus!
|
||||
audit.write(req,user,VeniceNamespaces.USER_EVENT_NAMESPACE,"verify.fail");
|
||||
dlg.setErrorMessage("Sorry, the confirmation number doesn't match. Please try again.");
|
||||
dlg.setValue("num",null);
|
||||
vlib.setLocation(req,target);
|
||||
vlib.setDisplayLogin(req,false);
|
||||
dynamo.scriptReturn(new FrameDialog(dlg));
|
||||
|
||||
} // end if
|
||||
|
||||
// we're verified - remove our confirmation number attribute
|
||||
audit.write(req,user,VeniceNamespaces.USER_EVENT_NAMESPACE,"verify.ok");
|
||||
user.removeObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"confirmation.number");
|
||||
|
||||
// add us to the "verified users" group
|
||||
srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
"srm"));
|
||||
srm.getVerifiedUsersGroup().addMember(user);
|
||||
|
||||
// and that does it - bounce us on to whereever we were going
|
||||
dynamo.scriptOutput(new Redirect("SERVLET",target));
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // unknown command button pressed!
|
||||
logger.error("no known button click on POST to verify_email.js");
|
||||
dynamo.scriptOutput(new ErrorBox("Internal Error","Unknown command button pressed","SERVLET",target));
|
||||
|
||||
} // end else
|
||||
Reference in New Issue
Block a user