Subversion Repository Public Repository

ChrisCompleteCodeTrunk

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
using System;
using System.Web;
using M3Workflow.Data;
using M3Workflow.Data.Base;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.SessionState;

namespace M3Workflow.Web
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {            
            this.labelErrorMessage.Visible = false;
            if (Request.QueryString["errorMessage"] != null)
            {
                this.labelErrorMessage.Visible = true;
                this.labelErrorMessage.Text = Request.QueryString["errorMessage"].ToString();
            }
        }


        private void CreateListTables(string cabinetName)
        {
            /* UNCOMMENT
            SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["IntelligentIndexingWorkflow"].ConnectionString);
            cn.Open();
            SqlCommand cmd = new SqlCommand("[dbo].[usp_CreateSelectListTables]", cn);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@CabinetName", cabinetName);
            cmd.ExecuteNonQuery();
            cn.Close();
            cn.Dispose();
            */
        }

        protected void buttonLogin_ServerClick(object sender, EventArgs e)
        {
            UserDataObject userDataObject = null;


            /* Uncomment this for testing 
            try
            {
                if (!Session.IsNewSession)
                {
                    Session.Clear();
                    SessionIDManager manager = new SessionIDManager();
                    string newID = manager.CreateSessionID(Context);
                    bool redirected = false;
                    bool isAdded = false;
                    manager.SaveSessionID(Context, newID, out redirected, out isAdded);
                    Session["SessionId"] = Session.SessionID;
                }
                userDataObject = M3DataProvider.Authenticate(inputUserName.Value, inputPassword.Value);
            }
            catch
            {
                Response.Redirect(
                    String.Format(
                        "Login.aspx?errorMessage={0}",
                        new object[]
                        {
                             HttpUtility.UrlEncode("Unable to autheticate.")
                        }
                    )
                );
            }
            */

            userDataObject = M3DataProvider.Authenticate(inputUserName.Value, inputPassword.Value);

            if (userDataObject != null && userDataObject.Token != null)
            {
                userDataObject.SetCredentials(
                    new AuthDataObject(inputUserName.Value, inputPassword.Value)
                );
                Session.Add("UserDataObject", userDataObject);
                Session["SessionId"] = Session.SessionID;
                foreach (UserCustomerObject customer in userDataObject.Customers)
                {
                    CreateListTables(customer.Cabinet);
                }
                Response.Redirect("Default.aspx");
            }
            else
            {
                Response.Redirect(
                    String.Format(
                        "Login.aspx?errorMessage={0}",
                        new object[]
                        {
                             HttpUtility.UrlEncode("Unable to connect to the authentication server with the supplied credentials.")
                        }
                    )
                );
            }
        }
    }
}

Commits for ChrisCompleteCodeTrunk/M3Workflow/M3Workflow.Web/Login.aspx.cs

Diff revisions: vs.
Revision Author Commited Message
1 BBDSCHRIS picture BBDSCHRIS Wed 22 Aug, 2018 20:08:03 +0000