Example #1
0
        public async Task <IActionResult> SavePresentation([FromBody] BoardPresentation boardPresentation)
        {
            if (!string.IsNullOrEmpty(boardPresentation.Id) && boardPresentation.Credentials.Password == null)
            {
                boardPresentation.Credentials = (await dbClient.GetPresentation(boardPresentation.Id)).Credentials;
            }

            if (ldapClient.CheckCredentials(boardPresentation.Credentials.Username, boardPresentation.Credentials.Password, false))
            {
                if (ModelState.IsValid)
                {
                    await dbClient.SavePresentationsAsync(boardPresentation);
                }
                else
                {
                    return(BadRequest("Invalid user input. Check allowed range for time values."));
                }

                boardPresentation.Credentials = null;
                return(Ok(boardPresentation));
            }
            else
            {
                return(Unauthorized());
            }
        }
Example #2
0
        public IActionResult Login([FromBody] Credentials credentials)
        {
            if (credentials.Username == "" || credentials.Password == "")
            {
                return(Unauthorized());
            }
            if (ldapClient.CheckCredentials(credentials.Username, credentials.Password))
            {
                var token = CreateToken(credentials);
                return(Ok(new
                {
                    token = new JwtSecurityTokenHandler().WriteToken(token)
                }));
            }

            return(Unauthorized());
        }