<%@page errorPage="oops.jsp" import="jabadot.*, java.io.*" %> <%! java.util.Random r = new java.util.Random(); %> <%@include file="header.html" %> <% // out.println(""); User user = (User)session.getAttribute("jabadot.login"); if (user != null) { %> You're already logged on!

You are logged on!

Please log out before trying to create a new account. Thank you! <% return; } %> <% // Now see if they already filled in the form or not... if (!newUserBean.isComplete()) { // out.println(""); %> Welcome New User - Please fill in this form.

Welcome New User - Please fill in this form.

The only required fields are login name, first name, last name, and email address.

Please be sure your email address is correct - we'll make up an initial password for you, and email to you a URL to download the password from. Watch your email closely after you complete the form. Thank you!

Login name: *
First Name: *
Last Name: *
Email Address: *
Company:
Address:
Address (continued):
City:
State/Province:
Postal Code:
Country
Appearance

Speaking of email, you can join several email lists by visiting our lists page. <% return; } // out.println(""); String nick = newUserBean.getName(); if (UserDB.getInstance().getUser(nick) != null) { %>

It seems that that user name is already in use! Please go back and pick another name. <% return; } %> <% String fullname = newUserBean.getFullName(); String email = newUserBean.getEmail(); %> Welcome <%= fullname %>. We will mail you (at <%= email %>) with a URL from which you can download your initial password. <% // Generate initial random password and store it in the User String newPass = Password.getNext().toString(); newUserBean.setPassword(newPass); // NOW add the user to the persistent database. UserDB.getInstance().addUser(newUserBean); // Create a temporary HTML file containing the full name // and the new password, and mail the URL for it to the user. // This will confirm that the user gave us a working email. // NEVER show the nickname and the password together! String tempDir = JDConstants.getProperty("jabadot.tmp_links_dir"); File tempLink = File.createTempFile( r.nextInt()+"$PW", ".html", new File(tempDir)); PrintWriter pw = new PrintWriter(new FileWriter(tempLink)); pw.print(""); pw.print("Greetings "); pw.print(newUserBean.getFullName()); pw.print(". Your new password for accessing JabaDot is "); pw.print(newPass); pw.print(". Please remember this, or better yet, "); pw.print(""); pw.print("login now!"); pw.print("You may want to visit \"My Jabadot\""); pw.print("and change this password after you log in."); pw.println(""); pw.close(); // Now we have to mail the URL to the user. mailBean.setFrom(JDConstants.getProperty("jabadot.mail_from")); mailBean.setSubject("Welcome to JabaDot!"); mailBean.addTo(email); mailBean.setServer(JDConstants.getProperty("jabadot.mail.server.smtp")); // Get our URL, strip off "newuser.jsp", append "/tmp/"+tmpname StringBuffer getPW_URL = HttpUtils.getRequestURL(request); int end = getPW_URL.length(); int start = end - "newuser.jsp".length(); getPW_URL.delete(start,end).append("tmp/").append(tempLink.getName()); mailBean.setBody("To receive your JabaDot password,\n" + "please visit the URL " + getPW_URL); // Now send the mail. mailBean.doSend(); // AVOID the temptation to sess.setAttribute() here, since // the user has not yet verified their password! %>