-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSessionCurrentUser.cs
134 lines (118 loc) · 3.78 KB
/
SessionCurrentUser.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
RMLib: Nonvisual support classes used by multiple R&M Software programs
Copyright (C) Rick Parrish, R&M Software
This file is part of RMLib.
RMLib is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
RMLib is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with RMLib. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Web;
namespace RandM.RMLib
{
public class SessionCurrentUser
{
public string Email
{
get { return _Email; }
set { _Email = value; Save(); }
}
private string _Email = "";
public string FirstName
{
get { return _FirstName; }
set { _FirstName = value; Save(); }
}
private string _FirstName = "";
public int GroupId
{
get { return _GroupId; }
set { _GroupId = value; Save(); }
}
private int _GroupId = 0;
public string LastName
{
get { return _LastName; }
set { _LastName = value; Save(); }
}
private string _LastName = "";
public string LFE
{
get { return _LFE; }
set { _LFE = value; Save(); }
}
private string _LFE = "";
public string Password
{
get { return _Password; }
set { _Password = value; Save(); }
}
private string _Password = "";
public int UserId
{
get { return _UserId; }
set { _UserId = value; Save(); }
}
private int _UserId = 0;
public string Username
{
get { return _Username; }
set { _Username = value; Save(); }
}
private string _Username = "";
public SessionCurrentUser()
{
if (HttpContext.Current.Session["SessionCurrentUser"] != null)
{
Hashtable HT = (Hashtable)HttpContext.Current.Session["SessionCurrentUser"];
_Email = HT["Email"].ToString();
_FirstName = HT["FirstName"].ToString();
_GroupId = (int)HT["GroupId"];
_LastName = HT["LastName"].ToString();
_LFE = HT["LFE"].ToString();
_Password = HT["Password"].ToString();
_UserId = (int)HT["UserId"];
_Username = HT["Username"].ToString();
}
}
public bool IsLoggedIn()
{
return ((_GroupId > 0) && (_UserId > 0));
}
public void LogOut()
{
HttpContext.Current.Session["SessionCurrentUser"] = null;
_Email = "";
_FirstName = "";
_GroupId = 0;
_LastName = "";
_LFE = "";
_Password = "";
_UserId = 0;
_Username = "";
}
private void Save()
{
Hashtable HT = new Hashtable();
HT["Email"] = _Email;
HT["FirstName"] = _FirstName;
HT["GroupId"] = _GroupId;
HT["LastName"] = _LastName;
HT["LFE"] = _LFE;
HT["Password"] = _Password;
HT["UserId"] = _UserId;
HT["Username"] = _Username;
HttpContext.Current.Session["SessionCurrentUser"] = HT;
}
}
}