feat: server login & register forms
This commit is contained in:
parent
ddfae53e76
commit
cbcf3067cb
3 changed files with 78 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"auth-server/logic"
|
||||
"context"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-oauth2/oauth2/v4/errors"
|
||||
|
@ -224,5 +225,24 @@ func main() {
|
|||
}
|
||||
}, srv))
|
||||
|
||||
http.HandleFunc("/login.html", func(w http.ResponseWriter, r *http.Request) {
|
||||
outputHTML(w, r, "static/login.html")
|
||||
})
|
||||
|
||||
http.HandleFunc("/register.html", func(w http.ResponseWriter, r *http.Request) {
|
||||
outputHTML(w, r, "static/register.html")
|
||||
})
|
||||
|
||||
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(config.AuthServerPort), nil))
|
||||
}
|
||||
|
||||
func outputHTML(w http.ResponseWriter, req *http.Request, filename string) {
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
fi, _ := file.Stat()
|
||||
http.ServeContent(w, req, file.Name(), fi.ModTime(), file)
|
||||
}
|
||||
|
|
29
auth-server/static/login.html
Normal file
29
auth-server/static/login.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
|
||||
<script src="//code.jquery.com/jquery-2.2.4.min.js"></script>
|
||||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Sign In</h1>
|
||||
<form action="/login" method="GET">
|
||||
<div class="form-group">
|
||||
<label for="client_id">User Name</label>
|
||||
<input type="text" class="form-control" name="client_id" required placeholder="Please enter your user name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="client_secret">Password</label>
|
||||
<input type="password" class="form-control" name="client_secret" placeholder="Please enter your password">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
29
auth-server/static/register.html
Normal file
29
auth-server/static/register.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
|
||||
<script src="//code.jquery.com/jquery-2.2.4.min.js"></script>
|
||||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Sign Up</h1>
|
||||
<form action="/register" method="GET">
|
||||
<div class="form-group">
|
||||
<label for="client_id">User Name</label>
|
||||
<input type="text" class="form-control" name="client_id" required placeholder="Please enter your user name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="client_secret">Password</label>
|
||||
<input type="password" class="form-control" name="client_secret" placeholder="Please enter your password">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">Register</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue