Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: added a stylish html after login #971

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions messages/login/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ const (
AskPassword = "Enter your password:"

//browser
VisitMsg = "Please visit https://sso.azion.com/login?next=cli in case it did not open automatically\n"
BrowserMsg = "You may now close this page and return to your terminal"
VisitMsg = "Please visit https://sso.azion.com/login?next=cli in case it did not open automatically\n"
)
65 changes: 63 additions & 2 deletions pkg/cmd/login/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package login

import (
"context"
"io"
"net/http"

msg "github.com/aziontech/azion-cli/messages/login"
Expand Down Expand Up @@ -44,7 +43,69 @@ func (l *login) browserLogin(srv Server) error {
if enableHandlerRouter {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
paramValue := r.URL.Query().Get("c")
_, _ = io.WriteString(w, msg.BrowserMsg)

htmlResponse := `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" sizes="32x32" href="https://avatars.githubusercontent.com/u/6660972?s=200&v=4">
<title>Azion</title>
<style>
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
font-family: Arial, sans-serif;
background-color: #f4f4f4;
}
.container {
text-align: center;
}
.logo {
width: 100px;
}
.text {
color: #000;
font-size: 12px;
margin-top: 20px;
}
.footer {
position: fixed;
bottom: 10px;
text-align: center;
width: 100%;
font-size: 14px;
color: #888;
}
.footer a {
color: #000;
text-decoration: none;
}
</style>
</head>
<body style="background: #ffffff;">
<div class="container">
<img src="https://avatars.githubusercontent.com/u/6660972?s=200&v=4" alt="Logo" class="logo">
<div class="text">Authenticated, you can now close this page and return to your terminal</div>
</div>
<div class="footer">
maxwelbm marked this conversation as resolved.
Show resolved Hide resolved
<p>&copy; 2024 <a href="https://github.com/aziontech", >Azion</a>. Licensed under the <a href="https://opensource.org/license/mit" target="_blank" style="color: #000;">Mit License</a>. All rights reserved.</p>
</div>
</body>
</html>`

w.Header().Set("Content-Type", "text/html")
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte(htmlResponse))
if err != nil {
logger.Error("Error render html", zap.Error(err))
}

if paramValue != "" {
tokenValue = paramValue
}
Expand Down
Loading