예제 #1
0
        public async Task LoginAsync(LoginOption option, CancellationToken ct)
        {
            option.OutputType = "json";
            var args = $"login {option} --cancel-from-stdin";

            await this.StartAZCopyAsync(args, ct);
        }
예제 #2
0
 public loginform(string startutl, string endurl, string userid, LoginOption option)
 {
     InitializeComponent();
     this.StartUrl     = startutl;
     this.EndUrl       = endurl;
     this.option       = option;
     this.FormClosing += FormGoogleLoginAuth_FormClosing;
 }
예제 #3
0
        public loginform(string startutl, string endurl, string userid, LoginOption option)
        {
           
            InitializeComponent();

            this.StartUrl = startutl;
            this.EndUrl = endurl;
            this.option = option;
            this.FormClosing += FormGoogleLoginAuth_FormClosing;
        }
예제 #4
0
        public LoginAnswerOption Login([FromBody] LoginOption loginOption)
        {
            LoginAnswerOption loginAnswerOption = loginService.TryLogin(loginOption);

            if (loginAnswerOption.TypeOfUser != null)
            {
                return(loginAnswerOption);
            }
            //ViewBag.CustomerType = loginAnswerOption.TypeOfUser;
            return(null);
        }
예제 #5
0
 public Authentication(string clientid, string clientsectet, string username, string path, string[] scopes, LoginOption option, string code = null)
 {
     this.clientId     = clientid;
     this.clientSecret = clientsectet;
     this.userName     = username;
     this.path         = path;
     this.scopes       = scopes;
     this.option       = option;
     this.code         = code;
     this.thread       = new Thread(new ThreadStart(this.CloudLogin));
 }
예제 #6
0
        protected override void Process(IClient client, CListEnd packet)
        {
            LoginOption         option    = client.GetOption <LoginOption>();
            SelectableCharacter character = option.SelectableCharacters.FirstOrDefault(x => option.CharacterSelector.Invoke(x));

            if (character == null)
            {
                Logger.Error("Can't found character matching predicate");
                return;
            }

            client.SendPacket($"select {character.Slot}");
            Logger.Debug($"Character {character.Name} selected");
        }
    void DisplayLogoutButton()
    {
        var user = Social.localUser;

        if (user != null && user.authenticated && currentUI != UI.Login)
        {
            if (GUILayout.Button("Log out"))
            {
                Social.Active = new LumosSocial();
                currentUI     = UI.Login;
                login         = LoginOption.None;
                message       = "";
            }
        }
    }
예제 #8
0
        public LoginAnswerOption TryLogin(LoginOption loginOption)
        {
            Backer backer = dbContext
                            .Set <Backer>()
                            .Where(o => o.FirstName == loginOption.Username && o.LastName == loginOption.Password)
                            .SingleOrDefault();

            if (backer != null)
            {
                return new LoginAnswerOption()
                       {
                           Id         = backer.Id,
                           TypeOfUser = "******"
                       }
            }
            ;
            ProjectCreator projectCreator = dbContext
                                            .Set <ProjectCreator>()
                                            .Where(o => o.FirstName == loginOption.Username && o.LastName == loginOption.Password)
                                            .SingleOrDefault();

            if (projectCreator.FirstName == "admin")
            {
                return new LoginAnswerOption()
                       {
                           Id         = projectCreator.Id,
                           TypeOfUser = "******"
                       }
            }
            ;
            if (projectCreator != null)
            {
                return new LoginAnswerOption()
                       {
                           Id         = projectCreator.Id,
                           TypeOfUser = "******"
                       }
            }
            ;

            return(new LoginAnswerOption()
            {
                Id = 0,
                TypeOfUser = null
            });
        }
    }
}
    void LoginScreen()
    {
        // Messages displayed after login or registration completes (fail or success)
        GUILayout.Label(message, GUILayout.Width(margin));

        // Select login/registration style
        if (login == LoginOption.None)
        {
            if (GUILayout.Button("Annonymous Login (auto register)", GUILayout.Width(margin)))
            {
                login = LoginOption.Annonymous;
                waitingForResponse = true;
                LumosSocialDemoCustomLogin.AuthenticateAnonymously();
            }

            if (GUILayout.Button("Username Only Login (register w/ username)", GUILayout.Width(margin)))
            {
                login = LoginOption.UsernameOnly;
            }

            if (GUILayout.Button("Full Login (register w/ username & password)", GUILayout.Width(margin)))
            {
                login = LoginOption.Full;
            }
            // Successfully registered or logged in
        }
        else if (login == LoginOption.Success)
        {
            if (GUILayout.Button("Continue", GUILayout.Width(margin)))
            {
                // Move on to a new UI.
                // This ends our demo.
                currentUI = UI.UserProfile;
            }
            // Failed to register/login
        }
        else if (login == LoginOption.Failed)
        {
            if (GUILayout.Button("Try Again", GUILayout.Width(margin)))
            {
                login   = LoginOption.None;
                message = "";
            }
            // Waiting for a response from the server
        }
        else if (waitingForResponse)
        {
            GUILayout.Label("Your request is being processed...", GUILayout.Width(margin));
            // Entering login/registration credentials
        }
        else
        {
            // Username field
            DisplayUsername();

            // Password field
            if (login == LoginOption.Full)
            {
                DisplayPassword();
            }

            // Login and Registration Buttons
            GUILayout.BeginHorizontal();
            var loggingIn   = GUILayout.Button(loginBtn, GUILayout.Width(margin));
            var registering = GUILayout.Button(registerBtn, GUILayout.Width(margin));

            if (loggingIn || registering)
            {
                // Login/Register with player defined username
                if (login == LoginOption.UsernameOnly)
                {
                    LumosSocialDemoCustomLogin.AuthenticateWithUsername(username, registering);
                    // Login/Register with player defined username and password
                }
                else
                {
                    LumosSocialDemoCustomLogin.Authenticate(username, password, registering);
                }

                waitingForResponse = true;
            }
            GUILayout.EndHorizontal();
        }
    }
 static void HandleResponse(bool success, string successMsg, string failMsg)
 {
     message            = (success) ? successMsg : failMsg;
     login              = (success) ? LoginOption.Success : LoginOption.Failed;
     waitingForResponse = false;
 }
예제 #11
0
        /// <summary>
        /// Sends a string to the server with the encoding
        /// defined in <see cref="CommunicationProperties.CommunicationEncoding"/>.
        /// </summary>
        private void Send(string text)
        {
            string json = string.Empty;

            // TODO: Converts the string into a command to the server:
            string[] args = text.Split(' ');
            if (args[0] == "login")
            {
                // Read command args:
                LoginOption login = new LoginOption();
                CommandLine.Parser.Default.ParseArguments(args, login);

                // Setup request and serialize it into a string:
                LoginRequest request = new LoginRequest()
                {
                    UserId = login.UserId
                };

                // Serialize the object into a JSON:
                json = request.SerializeToJson();

                // Send the requesr as JSON:
                this.SendRequest(json, this.ClientSocket);

                // Receive the response:
                string jsonResponse = this.ReceiveResponse(this.ClientSocket);

                // Deserialize response from JSON to object:
                LoginResponse response = jsonResponse.DeserializeFromJson <LoginResponse>();

                // Show possible pending messages:
                this.ShowMessages(response.Data.Messages);

                MessengerService.ClientId = request.UserId;
            }
            else if (args[0] == "send")
            {
                // Read command args:
                SendOption send = new SendOption();
                CommandLine.Parser.Default.ParseArguments(args, send);

                // Setup request and serialize it into a string:
                SendRequest request = new SendRequest()
                {
                    DestinationUserId = send.DestinationUser,
                    UserId            = MessengerService.ClientId,
                    Data = string.Join(" ", send.WordsInMessage)
                };

                // Serialize the object into a JSON:
                json = request.SerializeToJson();

                // Send the requesr as JSON:
                this.SendRequest(json, this.ClientSocket);

                // Receive the response:
                string jsonResponse = this.ReceiveResponse(this.ClientSocket);

                // Deserialize response from JSON to object:
                LoginResponse response = jsonResponse.DeserializeFromJson <LoginResponse>();
            }
            else if (args[0] == "logoff")
            {
                this.Logoff();
            }
            else
            {
                this.RemovePreviousLine();
            }
        }
	void DisplayLogoutButton ()
	{
		var user = Social.localUser;
		
		if (user != null && user.authenticated && currentUI != UI.Login) {
			if (GUILayout.Button("Log out")) {
				Social.Active = new LumosSocial();
				currentUI = UI.Login;
				login = LoginOption.None;
				message = "";
			}
		}
	}
예제 #13
0
        /// <summary>
        /// 얻어온 코드값을 반환해주는 함수 (뷰를 띄워주는 진입함수가 된다)
        /// </summary>
        /// <param name="clientId"> 클라이언트 id</param>
        /// <param name="scopes"> 접근 권한 주소가 담긴 list</param>
        /// <param name="userid"> 유저를 구분하기 위한 유저의 이름 (닉네임)</param>
        /// <param name="owner"> 부모 뷰의 핸들 (설정하지 않으면 기본값 null)</param>
        /// <returns></returns>
        public static async Task <string> GetAuthenticationToken(string clientId, IEnumerable <string> scopes, string userid, string starturl, string endurl, LoginOption option, IWin32Window owner = null)
        {
            string startUrl    = starturl;
            string realurl     = starturl;
            string completeUrl = endurl;
            string realendurl  = endurl;

            // 클라이언트 id와 접근 권한 리스트를 가지고 시작 url의 매개변수를 구성한다.
            GenerateUrlsForOAuth(clientId, scopes, out startUrl, out completeUrl, realurl, realendurl, option);
            // 만들어온 시작 url을 이용하여 로그인 폼을 새로 만든다.
            loginform authForm = new loginform(startUrl, completeUrl, userid, option);
            // 로그인 폼 화면을 띄워준다.
            DialogResult result = await authForm.ShowDialogAsync(owner);

            // 화면이 정상적으로 종료 되었을떄 실행
            if (DialogResult.OK == result)
            {
                // 얻어온 코드값을 반환해준다.
                return(OnAuthComplete(authForm.code));
            }
            return(null);
        }
예제 #14
0
 /// <summary>
 /// 서버 url로 넘겨줄 매개변수를 구성한다.
 /// </summary>
 /// <param name="clientId"></param>
 /// <param name="scopes"></param>
 /// <param name="startUrl"></param>
 /// <param name="completeUrl"></param>
 private static void GenerateUrlsForOAuth(string clientId, IEnumerable<string> scopes, out string startUrl, out string completeUrl, string realurl, string realendurl, LoginOption option)
 {
     // 파라미터 사전
     Dictionary<string, string> urlParam = new Dictionary<string, string>();
     urlParam.Add("client_id", clientId);
     if(LoginOption.DropBox != option)
     {
         urlParam.Add("scope", GenerateScopeString(scopes));
     }
     urlParam.Add("response_type", "code");
     //서버에서 되돌아오는 반환 uri 설정 인스톨 응용 프로그램은 urn:ietf:wg:oauth:2.0:oob
     if (LoginOption.DropBox != option)
     {
         urlParam.Add("redirect_uri", realendurl);
         if (option == LoginOption.GoogleDrive)
         {
             realendurl = "Success";
         }
         else if (LoginOption.OneDrive == option)
         {
             urlParam.Add("display", "popup");        
         }
         startUrl = BuildUriWithParameters(realurl, urlParam);
         completeUrl = realendurl;
         return;
     }
     startUrl = BuildUriWithParameters(realurl, urlParam);
     completeUrl = realendurl;
 }
예제 #15
0
 /// <summary>
 /// 얻어온 코드값을 반환해주는 함수 (뷰를 띄워주는 진입함수가 된다)
 /// </summary>
 /// <param name="clientId"> 클라이언트 id</param>
 /// <param name="scopes"> 접근 권한 주소가 담긴 list</param>
 /// <param name="userid"> 유저를 구분하기 위한 유저의 이름 (닉네임)</param>
 /// <param name="owner"> 부모 뷰의 핸들 (설정하지 않으면 기본값 null)</param>
 /// <returns></returns>
 public static async Task<string> GetAuthenticationToken(string clientId, IEnumerable<string> scopes, string userid, string starturl, string endurl, LoginOption option, IWin32Window owner = null)
 {
     string startUrl = starturl;
     string realurl = starturl;
     string completeUrl = endurl;
     string realendurl = endurl;
     // 클라이언트 id와 접근 권한 리스트를 가지고 시작 url의 매개변수를 구성한다.
     GenerateUrlsForOAuth(clientId, scopes, out startUrl, out completeUrl, realurl, realendurl, option);
     // 만들어온 시작 url을 이용하여 로그인 폼을 새로 만든다.
     loginform authForm = new loginform(startUrl, completeUrl, userid, option);
     // 로그인 폼 화면을 띄워준다.
     DialogResult result = await authForm.ShowDialogAsync(owner);
     // 화면이 정상적으로 종료 되었을떄 실행
     if (DialogResult.OK == result)
     {
         // 얻어온 코드값을 반환해준다.
         return OnAuthComplete(authForm.code);
     }
     return null;
 }
	static void HandleResponse (bool success, string successMsg, string failMsg)
	{
		message = (success) ? successMsg : failMsg;
		login = (success) ? LoginOption.Success : LoginOption.Failed;
		waitingForResponse = false;
	}
예제 #17
0
 public LoginAttribute()
 {
     Opt = LoginOption.Login;
 }
	void LoginScreen ()
	{
		// Messages displayed after login or registration completes (fail or success)
		GUILayout.Label(message, GUILayout.Width(margin));
		
		// Select login/registration style
		if (login == LoginOption.None) {
			if (GUILayout.Button("Annonymous Login (auto register)", GUILayout.Width(margin))) {
				login = LoginOption.Annonymous;
				waitingForResponse = true;
				LumosSocialDemoCustomLogin.AuthenticateAnonymously();
			}
		
			if (GUILayout.Button("Username Only Login (register w/ username)", GUILayout.Width(margin))) {
				login = LoginOption.UsernameOnly;
			}
		
			if (GUILayout.Button("Full Login (register w/ username & password)", GUILayout.Width(margin))) {
				login = LoginOption.Full;
			}
		// Successfully registered or logged in
		} else if (login == LoginOption.Success) {
			if (GUILayout.Button("Continue", GUILayout.Width(margin))) {
				// Move on to a new UI.
				// This ends our demo.
				currentUI = UI.UserProfile;
			}
		// Failed to register/login
		} else if (login == LoginOption.Failed) {
			if (GUILayout.Button("Try Again", GUILayout.Width(margin))) {
				login = LoginOption.None;
				message = "";
			}
		// Waiting for a response from the server
		} else if (waitingForResponse) {
			GUILayout.Label("Your request is being processed...", GUILayout.Width(margin));
		// Entering login/registration credentials
		} else {
			// Username field
			DisplayUsername();
			
			// Password field
			if (login == LoginOption.Full) {
				DisplayPassword();	
			}
			
			// Login and Registration Buttons
			GUILayout.BeginHorizontal();
				var loggingIn = GUILayout.Button(loginBtn, GUILayout.Width(margin));
				var registering = GUILayout.Button(registerBtn, GUILayout.Width(margin));
				
				if (loggingIn || registering) {
					// Login/Register with player defined username
					if (login == LoginOption.UsernameOnly) {
						LumosSocialDemoCustomLogin.AuthenticateWithUsername(username, registering);
					// Login/Register with player defined username and password
					} else {
						LumosSocialDemoCustomLogin.Authenticate(username, password, registering);
					}
				
					waitingForResponse = true;
				}
			GUILayout.EndHorizontal();
		}
	}
예제 #19
0
        /// <summary>
        /// 서버 url로 넘겨줄 매개변수를 구성한다.
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="scopes"></param>
        /// <param name="startUrl"></param>
        /// <param name="completeUrl"></param>
        private static void GenerateUrlsForOAuth(string clientId, IEnumerable <string> scopes, out string startUrl, out string completeUrl, string realurl, string realendurl, LoginOption option)
        {
            // 파라미터 사전
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("client_id", clientId);
            if (LoginOption.DropBox != option)
            {
                urlParam.Add("scope", GenerateScopeString(scopes));
            }
            urlParam.Add("response_type", "code");
            //서버에서 되돌아오는 반환 uri 설정 인스톨 응용 프로그램은 urn:ietf:wg:oauth:2.0:oob
            if (LoginOption.DropBox != option)
            {
                urlParam.Add("redirect_uri", realendurl);
                if (option == LoginOption.GoogleDrive)
                {
                    realendurl = "Success";
                }
                else if (LoginOption.OneDrive == option)
                {
                    urlParam.Add("display", "popup");
                }
                startUrl    = BuildUriWithParameters(realurl, urlParam);
                completeUrl = realendurl;
                return;
            }
            startUrl    = BuildUriWithParameters(realurl, urlParam);
            completeUrl = realendurl;
        }
예제 #20
0
        private async void LoginProcess(string clientid, string clientsecret, string AuthorizationUri, string RedirectUri, string TokenUri, string savenaem, string username, string path, string[] scope, LoginOption option)
        {
            FileDataStore datastore = new FileDataStore(path);

            Authentication.UserNameToken token = await Authentication.LoadToken(datastore, savenaem, CancellationToken.None);

            string code = null;

            if (token == null)
            {
                code = await loginform.GetAuthenticationToken(clientid, scope, username, AuthorizationUri, RedirectUri, option);
            }
            if ((token != null && code == null) || (token == null && code != null))
            {
                ShowProgress();
                login           = new Authentication(clientid, clientsecret, username, path, scope, option, code);
                login.complete += login_complete;
                login.start();
            }
        }