root/trunk/website/forums/login.cfm

Revision 5, 8.0 kB (checked in by DanWilson, 17 years ago)

Initial Commit Of ModelGlue? Website (upgrade to blogcfc 511)

Line 
1<cfsetting enablecfoutputonly=true>
2<!---
3        Name         : newthread.cfm
4        Author       : Raymond Camden
5        Created      : June 10, 2004
6        Last Updated : February 21, 2007
7        History      : Support password reminders (rkc 2/18/05)
8                                   No more notifications (rkc 7/29/05)
9                                   Removed mappings (rkc 8/27/05)
10                                   require confirmation changes (rkc 7/12/06)
11                                   make title work (rkc 8/4/06)
12                                   handle encryption and auto-focus (rkc 11/3/06)
13                                   param a few fields I was assuming existed (rkc 2/21/07)
14        Purpose          : Displays form to add a thread.
15--->
16
17<!--- Loads header --->
18<cfmodule template="tags/layout.cfm" templatename="main" title="#application.galleon.settings.title#">
19
20<cfparam name="form.username_new" default="">
21<cfparam name="form.emailaddress" default="">
22<cfparam name="form.password_new" default="">
23<cfparam name="form.password_new2" default="">
24
25<cfset failedLogon = false>
26
27<!--- did they try to logon and succeeed? --->
28<cfif isDefined("form.logon")>
29        <cfif request.udf.isLoggedOn()>
30                <cfif isDefined("url.ref")>
31                        <cflocation url="#url.ref#" addToken="false">
32                <cfelse>
33                        <cflocation url="index.cfm" addToken="false">
34                </cfif>
35        <cfelse>
36                <cfset failedlogon = true>
37        </cfif>
38</cfif>
39
40<!--- Handle attempted registration --->
41<cfif isDefined("form.register")>
42        <cfset errors = "">
43
44        <cfif not len(trim(form.username_new)) or not request.udf.isValidUsername(form.username_new)>
45                <cfset errors = errors & "You must enter a username. Only letters and numbers are allowed.<br>">
46        </cfif>
47       
48        <cfif not len(trim(form.emailaddress)) or not request.udf.isEmail(form.emailaddress)>
49                <cfset errors = errors & "You must enter a valid email address.<br>">
50        </cfif>
51       
52        <cfif not isDefined("form.password_new") or not len(trim(form.password_new)) or form.password_new neq form.password_new2>
53                <cfset errors = errors & "You must enter a valid password that matches the confirmation.<br>">
54        </cfif>
55       
56        <cfif not len(errors)>
57       
58                <cftry>
59               
60                        <cfset application.galleon.user.addUser(trim(form.username_new),trim(form.password_new),trim(form.emailaddress),"forumsmember")>
61                        <cfset mygroups = application.galleon.user.getGroupsForUser(trim(form.username_new))>
62       
63                        <!--- Only login if no confirmation needed --->
64                        <cfif not application.galleon.settings.requireconfirmation>
65                                <cflogin>
66                                        <cfset session.user = application.galleon.user.getUser(trim(form.username_new))>               
67                                        <cfloginuser name="#trim(form.username_new)#" password="#trim(form.password_new)#" roles="#mygroups#">
68                                </cflogin>
69                               
70                                <cfif isDefined("url.ref")>
71                                        <cflocation url="#url.ref#" addToken="false">
72                                <cfelse>
73                                        <cflocation url="index.cfm" addToken="false">
74                                </cfif>
75                        <cfelse>
76                                <cfset showRequireConfirmation = true>
77                        </cfif>
78                        <cfcatch type="user cfc">
79                                <cfif findNoCase("User already exists",cfcatch.message)>
80                                        <cfset errors = errors & "This username already exists.<br>">
81                                </cfif>
82                        </cfcatch>
83                        <cfcatch type="any.foo">
84                                <cfset errors = "General DB error.">
85                                <!---
86                                <cfdump var="#cfcatch.detail#">
87                                <cfdump var="#cfcatch.message#">
88                                <cfdump var="#cfcatch.tagcontext#">
89                                <cfdump var="#cfcatch#">
90                                --->
91                        </cfcatch>
92                </cftry>
93
94        </cfif>
95               
96</cfif>
97
98<cfif isDefined("form.reminder") and len(trim(form.username_lookup))>
99        <cfset data = application.galleon.user.getUser(trim(form.username_lookup))>
100        <cfif data.emailaddress is not "">
101                <cfmail to="#data.emailaddress#" from="#application.galleon.settings.fromAddress#" subject="Galleon Password Reminder">
102This is a password reminder from the Galleon Forums at #application.galleon.settings.rooturl#.
103Your password is: #data.password#
104                </cfmail>
105                <cfset sentInfo = true>
106        </cfif>
107</cfif>
108
109<cfoutput>
110<p>
111<table width="500" cellpadding="6" class="tableDisplay" cellspacing="1" border="0">
112        <cfif structKeyExists(variables, "showRequireConfirmation")>
113                <tr class="tableHeader">
114                        <td class="tableHeader">Confirmation Required</td>
115                </tr>
116                <tr class="tableRowMain">
117                        <td>
118                        In order to complete your registration, you must confirm your email
119                        address. An email has been sent to the address you used during registration.
120                        Follow the link in the email to complete registration.
121                        </td>
122                </tr>
123       
124        <cfelse>
125                <tr class="tableHeader">
126                        <td class="tableHeader">Login</td>
127                </tr>
128                <tr class="tableRowMain">
129                        <td>
130                        Please use the form below to login.
131                        <cfif failedLogon>
132                        <p>
133                        <cfif application.galleon.settings.requireconfirmation>
134                        <b>Either your username and password did not match or you have not completed your email confirmation.</b>
135                        <cfelse>
136                        <b>Your username and password did not work.</b>
137                        </cfif>
138                        </p>
139                        </cfif>
140                        </td>
141                </tr>
142                <tr class="tableRowMain">
143                        <td>
144                        <form action="#cgi.script_name#?#cgi.query_string#" method="post">
145                        <input type="hidden" name="logon" value="1">
146                        <table>
147                                <tr>
148                                        <td><b>Username:</b></td>
149                                        <td><input type="text" name="username" id="username" class="formBox"></td>
150                                </tr>
151                                <tr>
152                                        <td><b>Password:</b></td>
153                                        <td><input type="password" name="password" class="formBox"></td>
154                                </tr>
155                                <tr>
156                                        <td>&nbsp;</td>
157                                        <td align="right"><input type="image" src="images/btn_login.gif" alt="Login" width="71" height="19" name="logon"></td>
158                                </tr>
159                        </table>
160                        </form>
161                        </td>
162                </tr>
163                <tr class="tableHeader">
164                        <td class="tableHeader">Register</td>
165                </tr>
166                <tr class="tableRowMain">
167                        <td>
168                        In order to create threads or reply to threads, you must register. All of the
169                        fields below are required.
170                        <cfif isDefined("errors")>
171                                <p>
172                                Please correct the following error(s):<ul><b>#errors#</b></ul>
173                                </p>
174                        </cfif>
175                        </td>
176                </tr>
177                <tr class="tableRowMain">
178                        <td>
179                        <form action="#cgi.script_name#?#cgi.query_string#" method="post">
180                        <input type="hidden" name="register" value="1">
181                        <table>
182                                <tr>
183                                        <td><b>Username: </b></td>
184                                        <td><input type="text" name="username_new" value="#form.username_new#" class="formBox"></td>
185                                </tr>
186                                <tr>
187                                        <td><b>Email Address: </b></td>
188                                        <td><input type="text" name="emailaddress" value="#form.emailaddress#" class="formBox"></td>
189                                </tr>
190                                <tr>
191                                        <td><b>Password: </b></td>
192                                        <td><input type="password" name="password_new" class="formBox"></td>
193                                </tr>
194                                <tr>
195                                        <td><b>Confirm Password: </b></td>
196                                        <td><input type="password" name="password_new2" class="formBox"></td>
197                                </tr>
198                                <tr>
199                                        <td>&nbsp;</td>
200                                        <td align="right"><input type="image" src="images/btn_register.gif" alt="Register" width="71" height="19"></td>
201                                </tr>
202                        </table>
203                        </form>
204                        </td>
205                </tr>
206                <cfif application.galleon.settings.encryptpasswords>
207                <cfelse>
208                <tr class="tableHeader">
209                        <td class="tableHeader">Password Reminder</td>
210                </tr>
211                <tr class="tableRowMain">
212                        <td>
213                        If you cannot remember your password, enter your username in the form below and your login information will be sent to you.
214                        <cfif isDefined("form.reminder")>
215                                <cfif isDefined("variables.sentInfo")>
216                                <p>
217                                A reminder has been sent to your email address.
218                                </p>
219                                <cfelse>
220                                <p>
221                                Sorry, but your username could not be found in our system.
222                                </p>
223                                </cfif>
224                        </cfif>
225                        </td>
226                </tr>
227                <tr class="tableRowMain">
228                        <td>
229                        <form action="#cgi.script_name#?#cgi.query_string#" method="post">
230                        <input type="hidden" name="reminder" value="1">
231                        <table>
232                                <tr>
233                                        <td><b>Username:</b></td>
234                                        <td><input type="text" name="username_lookup" class="formBox"></td>
235                                </tr>
236                                <tr>
237                                        <td>&nbsp;</td>
238                                        <td align="right"><input type="image" src="images/btn_sendpasswordreminder.gif" alt="Login" width="149" height="19" name="logon"></td>
239                                </tr>
240                        </table>
241                        </form>
242                        </td>
243                </tr>
244                </cfif>
245        </cfif>
246</table>
247</p>
248
249<script>
250window.onload = function() {document.getElementById("username").focus();}
251</script>
252</cfoutput>
253       
254</cfmodule>
255
256<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.