-
Notifications
You must be signed in to change notification settings - Fork 0
/
MojoPortalUser.cs
111 lines (99 loc) · 3.02 KB
/
MojoPortalUser.cs
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System;
using System.Data.SqlClient;
using System.Web;
using yaf;
using mojoPortal.Business;
using mojoPortal.Web;
namespace yaf
{
public class MojoPortalUser : IForumUser
{
private string m_email;
private string m_firstName;
private bool m_isAuthenticated = false;
private bool m_isSuperAdmin = false;
private string m_lastName;
private string m_location;
private int m_userID;
private string m_userName = "";
private SiteUser siteUser;
public MojoPortalUser()
{
try
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
//UserInfo info = UserController.GetUserByName(((PortalSettings) HttpContext.Current.Items["PortalSettings"]).get_PortalId(), HttpContext.Current.User.Identity.Name, false);
siteUser = SiteUtils.GetCurrentSiteUser();
this.m_userID = siteUser.UserId;
this.m_userName = siteUser.LoginName;
this.m_email = siteUser.Email;
this.m_firstName = siteUser.Name;
this.m_lastName = "";
this.m_location = siteUser.Country;
this.m_isSuperAdmin = siteUser.IsInRoles("Administrators");
this.m_isAuthenticated = true;
}
}
catch (Exception exception)
{
throw new Exception("Failed to find user info from mojoPortal.", exception);
}
}
public void UpdateUserInfo(int userID)
{
using (SqlCommand command = new SqlCommand())
{
command.CommandText = string.Format("update yaf_User set Email='{0}' where UserID={1}", this.m_email, userID);
DB.ExecuteNonQuery(command);
if (this.m_isSuperAdmin)
{
command.CommandText = string.Format("update yaf_User set Flags = Flags | 3 where UserID={0}", userID);
DB.ExecuteNonQuery(command);
}
}
}
public bool CanLogin
{
get
{
return false;
}
}
public string Email
{
get
{
return this.m_email;
}
}
public object HomePage
{
get
{
return null;
}
}
public bool IsAuthenticated
{
get
{
return this.m_isAuthenticated;
}
}
public object Location
{
get
{
return this.m_location;
}
}
public string Name
{
get
{
return this.m_userName;
}
}
}
}