forked from OPSI-srl/UManage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLauncher.ascx.cs
117 lines (80 loc) · 3.33 KB
/
Launcher.ascx.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
using System;
using System.Web.UI.WebControls;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Users;
using System.Web;
namespace OPSI.UManage.Pages
{
public partial class Launcher : PortalModuleBase
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
DotNetNuke.Framework.ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
DotNetNuke.Framework.ServicesFramework.Instance.RequestAjaxScriptSupport();
if (Request["iu"] != null)
{
if (Request["iu"].ToString() != "")
{
// impersoniamo un caro utonto
int uid = int.Parse(Request["iu"].ToString());
//UserInfo MyUserInfo = UserController.GetUser(this.PortalId, uid, true);
UserInfo MyUserInfo = UserController.GetUserById(this.PortalId, uid);
if ((MyUserInfo != null))
{
//Remove user from cache
if (Page.User != null)
{
DotNetNuke.Common.Utilities.DataCache.ClearUserCache(this.PortalSettings.PortalId, Context.User.Identity.Name);
}
// sign current user out
PortalSecurity objPortalSecurity = new PortalSecurity();
objPortalSecurity.SignOut();
// sign new user in
UserController.UserLogin(PortalId, MyUserInfo, PortalSettings.PortalName, Request.UserHostAddress, false);
// redirect to the base url
if (HttpContext.Current.Request.IsSecureConnection)
{
Response.Redirect("https://" + PortalSettings.PortalAlias.HTTPAlias, true);
}
else
{
Response.Redirect("http://" + PortalSettings.PortalAlias.HTTPAlias, true);
}
}
}
}
//Module is not usuable by unauthenticated users
if (UserInfo.UserID <= 0)
{
this.panel_unregistereduser.Visible = true;
this.panel_normal.Visible = false;
return;
}
if (this.IsPostBack == false)
{
if (Session["UManage_StopAutoLauncher"] == null)
{
LaunchModule();
}
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
public void lnk_launcher_click(object sender, EventArgs e)
{
LaunchModule();
}
public void LaunchModule()
{
Response.Redirect(EditUrl("", "", "main", "SkinSrc=%5BG%5DSkins%2f_default%2fNo+Skin&ContainerSrc=%5BG%5DContainers%2f_default%2fNo+Container"));
}
}
}