Inheritance: ADBaseLibrary.Response, ISession
コード例 #1
0
 public ISession Deserialize(Dictionary<string, string> data)
 {
     DaiSukiSession ses = new DaiSukiSession();
     ses.cookies = data;
     return ses;
 }
コード例 #2
0
        public async Task<ISession> Authenticate(Dictionary<string, object> authenticationmetadata)
        {
            _authmeta = authenticationmetadata;
            DaiSukiSession session = new DaiSukiSession();
            try
            {
                Response r = await _info.VerifyBaseAuthentication(authenticationmetadata);
                if (r.Status != ResponseStatus.Ok)
                {
                    r.PropagateError(session);
                    return session;
                }
                Dictionary<string, string> form = new Dictionary<string, string>();
                form.Add("emailAddress", authenticationmetadata.GetStringFromMetadata(DownloadPluginInfo.Username));
                form.Add("password", authenticationmetadata.GetStringFromMetadata(DownloadPluginInfo.Password));
                form.Add("keepLogin", "on");


                
                WebStream ws = await WebStream.Post("https://www.daisuki.net/bin/SignInServlet.html/input", form, null, LibSet[UserAgentS], null, null, SocketTimeout, true, "http://www.daisuki.net/", _info.ProxyFromGlobalRequirements(_global));
                if (ws != null && ws.StatusCode == HttpStatusCode.OK)
                {

                    if (!VerifyLogin(ws.Cookies))
                    {
                        session.Status = ResponseStatus.InvalidLogin;
                        session.ErrorMessage = "Invalid Account Information";
                        session.cookies = new Dictionary<string, string>();
                    }
                    else
                    {
                        session.cookies = ws.Cookies.ToDictionary();
                        session.Status = ResponseStatus.Ok;
                    }
                }
                else
                {
                    SetWebError(session);
                }
                ws?.Dispose();
            }
            catch (Exception e)
            {
                session.Status = ResponseStatus.SystemError;
                session.ErrorMessage = e.ToString();

            }
            return session;

        }