コード例 #1
0
        public async Task <IHttpActionResult> Auth([FromBody] Auth.Login data)
        {
            var user = await Resources.Database.User.Get.ByUsername(data.username);

            if (user != null)
            {
                if (Functions.Decode.Base64toString(user.password) == Functions.Decode.Base64toString(data.password) &&
                    await Resources.Database.User.Check.IsAdmin(data))
                {
                    await Resources.Database.User.Set.LastLogon(user);

                    await History.Create(History.Type.API, new History_API()
                    {
                        api_action   = "Administration -> User  '" + user.username + "' loged on",
                        api_datetime = DateTime.Now,
                        api_type     = "Admin log on"
                    });

                    return(Ok(new User_Info()
                    {
                        unique_id = user.unique_id, username = user.username
                    }));
                }
                return(Unauthorized());
            }
            return(NotFound());
        }
コード例 #2
0
        protected override void FinishCallback(string json)
        {
            CreateResponse data = GetData <CreateResponse>(json);

            UserManager.SetApiInfo(data.uuid, data.password);

            //ログイン
            Auth.Login authLogin = new Auth.Login();
            authLogin.SetApiFinishCallback(apiFinishCallback);
            authLogin.Exe();
        }
コード例 #3
0
ファイル: API.cs プロジェクト: zpangrsic/BigMovieProject
 /// <summary>
 /// Login user and retrieve auth user parameters
 /// </summary>
 /// <param name="data">Auth.Login</param>
 /// <returns>HttpResponseMessage</returns>
 public static async Task <HttpResponseMessage> Login(Auth.Login data)
 {
     try
     {
         return(await Administration.Auth(Create.HttpContent <Auth.Login>(data)));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "An error occured", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(null);
     }
 }
コード例 #4
0
        public async Task <IHttpActionResult> Login([FromBody] Auth.Login data)
        {
            var user = await Resources.Database.User.Get.ByUsername(data.username);

            if (user != null)
            {
                if (user.username == data.username && user.password == data.password)
                {
                    user.last_logon = DateTime.Now; db.SaveChanges();
                    await History.Create(History.Type.User, new History_User()
                    {
                        user_action   = "Login authorization -> " + user.unique_id,
                        user_datetime = DateTime.Now,
                        user_id       = user.unique_id,
                        user_movie    = "",
                        user_type     = "Authorized"
                    });

                    return(Ok(new DatabaseUserModels()
                    {
                        user_id = user.unique_id
                    }));
                }
                else
                {
                    await History.Create(History.Type.User, new History_User()
                    {
                        user_action   = "Login authorization -> " + user.unique_id,
                        user_datetime = DateTime.Now,
                        user_id       = user.unique_id,
                        user_movie    = "",
                        user_type     = "NotAuthorized"
                    });

                    return(Unauthorized());
                }
            }
            else
            {
                return(NotFound());
            }
        }