forked from cfjedimaster/ColdFusion-Blog-Aggregator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.cfm
83 lines (71 loc) · 2.2 KB
/
user.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!---
Name : user.cfm
Author : Raymond Camden
Created : August 5, 2007
Last Updated :
History :
Purpose :
--->
<cfset doneflag = false>
<cfset errors = "">
<cfparam name="form.name" default="#session.user.getName()#">
<cfparam name="form.email" default="#session.user.getEmail()#">
<cfif structKeyExists(form, "userprefs")>
<cfif not len(trim(form.name))>
<cfset errors = errors & "You must enter a name.<br />">
<cfelse>
<cfset form.name = htmlEditFormat(form.name)>
</cfif>
<cfif not len(trim(form.email)) or not isValid("email", form.email)>
<cfset errors = errors & "You must enter a valid email address.<br />">
</cfif>
<cfif len(trim(form.newpassword)) and form.newpassword neq form.password2>
<cfset errors = errors & "If you want to change your password, the confirm password must match.<br />">
</cfif>
<cfif errors is "">
<cftry>
<cfinvoke component="#application.user#" method="updateUserPreferences">
<cfinvokeargument name="userid" value="#session.user.getID()#">
<cfinvokeargument name="name" value="#form.name#">
<cfinvokeargument name="email" value="#form.email#">
<cfif len(trim(form.newpassword))>
<cfinvokeargument name="password" value="#form.newpassword#">
</cfif>
</cfinvoke>
<!--- reget the bean --->
<cfset session.user = application.user.getUser(session.user.getID())>
<cfset doneFlag = true>
<cfcatch>
<cfset errors = cfcatch.message & "<br />">
</cfcatch>
</cftry>
</cfif>
</cfif>
<cfif doneFlag>
<p>
<b>User details updated.</b>
</p>
</cfif>
<cfif len(errors)>
<cfoutput>
<p>
<b>Please correct these errors:<br/>#errors#</b>
</p>
</cfoutput>
</cfif>
<cfform action="user.cfm" method="post">
<cfoutput>
<p>
<label>Update Password</label>
<input name="newpassword" type="password" size="30" />
<label>Confirm New Password</label>
<input name="password2" type="password" size="30" />
<label>Name</label>
<input name="name" type="text" size="30" value="#form.name#" />
<label>Email Address</label>
<input name="email" type="text" size="30" value="#form.email#" />
<br /><br />
<input class="button" type="submit" name="userprefs" value="Update User Details"/>
</p>
</cfoutput>
</cfform>