protected void buttonIAgree_Click(object sender, EventArgs e) { string sUsername = Session["LoggedIn"] as string; int UserId = ShiptalkPrincipal.UserId; //Since User agreed to the privacy agreement, redirect him to requested page. LastLoginInfo loginInfo = UserBLL.GetLastLoginInfo(sUsername); Guid NewSessionToken = Guid.NewGuid(); UserBLL.UpdateUserSessionToken(UserId, NewSessionToken); FormsAuthenticationTicket tkt = new FormsAuthenticationTicket( 2, sUsername, loginInfo.LastLoginAttempt.Value, loginInfo.LastLoginAttempt.Value.AddMinutes(ShiptalkCommon.ConfigUtil.SessionTimeOutInMinutes), false, NewSessionToken.ToString() + "|" + loginInfo.LastLoginAttempt.Value.ToString()); string encryptedTkt = FormsAuthentication.Encrypt(tkt); HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTkt); authCookie.HttpOnly = true; Response.Cookies.Add(authCookie); //sammit: Crate a timespan of 1 sec System.TimeSpan diffResult = new TimeSpan(0, 0, 1); if (loginInfo.LastPasswordChangeDate != null) { diffResult = DateTime.Now.Subtract(loginInfo.LastPasswordChangeDate.Value); } if (diffResult.TotalDays >= ConfigUtil.PasswordWarningAfterHowManyDays) { pnlPrivacy.Visible = false; pnlPwdchange.Visible = true; lblNoOfDays.Text = (60 - Math.Floor(diffResult.TotalDays)).ToString(); return; } else { //////string Unqiue_Browser_Window_Guid = Guid.NewGuid().ToString(); //////Session.Add("WINDOW_GUID", Unqiue_Browser_Window_Guid); //////Response.AddHeader("WINDOW_GUID", Unqiue_Browser_Window_Guid); //Sammit commented out this line. Always go to usersearchpage ///// Response.Redirect(FormsAuthentication.GetRedirectUrl(sUsername, false)); Response.Redirect("~/user/usersearch"); } }
public LastLoginBLL(FormsAuthenticationTicket ticket) { if (ticket == null) { throw new ArgumentNullException("ticket"); } else { this.ticket = ticket; DBLoginInfo = UserBLL.GetLastLoginInfo(ticket.Name); } }
private void EncryptedPacketHandler(byte[] recvbuf, int buflen) { if (buflen == 0) { Console.WriteLine("Client sent empty packet. Disconnecting..."); IsConnected = false; return; } byte[] arrData = new byte[buflen]; Array.Copy(recvbuf, arrData, buflen); C2S_Crypto.decrypt(arrData); Octet data = new Octet(arrData); byte packetid = data.UnMarshalByte(); switch (packetid) { case (byte)LinkServerPacket.KeyExchange: CMKey smkeyPacket = new CMKey(data); _cmKey = smkeyPacket.GetCMKey(); HMACMD5 hmacmd5 = new HMACMD5(Encoding.ASCII.GetBytes(_username)); byte[] array = new byte[_passwordHash.Length + _cmKey.Length]; _passwordHash.CopyTo(array, 0); _cmKey.CopyTo(array, _passwordHash.Length); byte[] RC4_S2CKEY = hmacmd5.ComputeHash(array); S2C_Crypto = new RC4(RC4_S2CKEY); _isCompressed = true; _userId = _database.GetIdByUsername(_username); OnlineAnnounce announcePacket = new OnlineAnnounce(_userId); SendReply(announcePacket.GetBytes()); break; case (byte)LinkServerPacket.RoleList: RoleList roleListPacket = new RoleList(data); Console.WriteLine("TODO: Get Roles by ID"); LastLoginInfo loginInfo = new LastLoginInfo(_userId); SendReply(loginInfo.GetBytes()); //Console.WriteLine("TODO: Iterate over roles and send them"); //// Finally... //RoleListRe finalRole = new RoleListRe(-1, _userId); //SendReply(finalRole.GetBytes()); break; default: IsConnected = false; Console.WriteLine("Unknown packet. Disconnecting..."); Console.WriteLine(BitConverter.ToString(arrData, 0, arrData.Length)); break; } }