private Stream SetToken(string user, string password, string appctx) { string html = ""; if (platform.IsValidUser(user, password)) { SafeTokenHandler tokenHandler = new HomeOS.Hub.Common.SafeTokenHandler.SafeTokenHandler(Constants.TokenEncryptionSecret); string token = HttpUtility.UrlEncode(tokenHandler.GenerateToken(user)); html = "<html>" + redirectJS + "<script type='text/javascript'> redirect('redirect?stoken=" + token + "&appctx=" + appctx + "&action=login&scheme=" + user + " '); </script></html>"; } else { html = "<html><h1>Not Authenticated</h1><h2><a href='" + appctx + "'>Click here</a> to go back</h2></html>"; } if (WebOperationContext.Current != null) { WebOperationContext.Current.OutgoingResponse.ContentType = "text/html"; } byte[] htmlBytes = Encoding.UTF8.GetBytes(html); return(new MemoryStream(htmlBytes)); }
private Stream SetToken(string user, string password, string appctx) { string html = ""; if (platform.IsValidUser(user, password)) { SafeTokenHandler tokenHandler = new HomeOS.Hub.Common.SafeTokenHandler.SafeTokenHandler(Constants.TokenEncryptionSecret); string token = HttpUtility.UrlEncode(tokenHandler.GenerateToken(user)); html = "<html>" + redirectJS + "<script type='text/javascript'> redirect('redirect?stoken=" + token + "&appctx=" + appctx + "&action=login&scheme=" + user + " '); </script></html>"; } else { html = "<html><h1>Not Authenticated</h1><h2><a href='" + appctx + "'>Click here</a> to go back</h2></html>"; } if (WebOperationContext.Current != null) WebOperationContext.Current.OutgoingResponse.ContentType = "text/html"; byte[] htmlBytes = Encoding.UTF8.GetBytes(html); return new MemoryStream(htmlBytes); }