|
@@ -13,7 +13,7 @@ import (
|
|
"github.com/valyala/fasttemplate"
|
|
"github.com/valyala/fasttemplate"
|
|
)
|
|
)
|
|
|
|
|
|
-//ClientInformationStruct export
|
|
|
|
|
|
+//ClientsInformationStruct export
|
|
type ClientsInformationStruct []struct {
|
|
type ClientsInformationStruct []struct {
|
|
ClientID string `json:"client-id"`
|
|
ClientID string `json:"client-id"`
|
|
ClientSecret string `json:"client-secret"`
|
|
ClientSecret string `json:"client-secret"`
|
|
@@ -23,6 +23,20 @@ type ClientsInformationStruct []struct {
|
|
Scope []string `json:"scope"`
|
|
Scope []string `json:"scope"`
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//UsersInformationStruct shouldn be exported
|
|
|
|
+type UsersInformationStruct []struct {
|
|
|
|
+ Scope []struct {
|
|
|
|
+ Name string `json:"name"`
|
|
|
|
+ Value string `json:"value"`
|
|
|
|
+ } `json:"scope"`
|
|
|
|
+ Granted []struct {
|
|
|
|
+ ClientID struct {
|
|
|
|
+ Scope []string `json:"scope"`
|
|
|
|
+ Status string `json:"status"`
|
|
|
|
+ } `json:"client-id"`
|
|
|
|
+ } `json:"granted"`
|
|
|
|
+}
|
|
|
|
+
|
|
func main() {
|
|
func main() {
|
|
http.HandleFunc("/login", loginHandler)
|
|
http.HandleFunc("/login", loginHandler)
|
|
http.HandleFunc("/chklogin", chkloginHandler)
|
|
http.HandleFunc("/chklogin", chkloginHandler)
|
|
@@ -56,10 +70,15 @@ func loginHandler(w http.ResponseWriter, r *http.Request) {
|
|
func chkloginHandler(w http.ResponseWriter, r *http.Request) {
|
|
func chkloginHandler(w http.ResponseWriter, r *http.Request) {
|
|
// Call ParseForm() to parse the raw query and update r.PostForm and r.Form.
|
|
// Call ParseForm() to parse the raw query and update r.PostForm and r.Form.
|
|
if err := r.ParseForm(); err != nil {
|
|
if err := r.ParseForm(); err != nil {
|
|
- fmt.Fprintf(w, "ParseForm() err: %v", err)
|
|
|
|
- return
|
|
|
|
|
|
+ errHandler(w, r, "Missing post parameter")
|
|
|
|
+ }
|
|
|
|
+ data, err := ioutil.ReadFile("./user.json")
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Print(err)
|
|
}
|
|
}
|
|
- fmt.Fprintf(w, "Post from website! r.PostFrom = %v\n", r.PostForm)
|
|
|
|
|
|
+ var UsersInformation UsersInformationStruct
|
|
|
|
+ err = json.Unmarshal(data, &UsersInformation)
|
|
|
|
+
|
|
email := r.FormValue("email")
|
|
email := r.FormValue("email")
|
|
password := r.FormValue("password")
|
|
password := r.FormValue("password")
|
|
fmt.Println(email, password)
|
|
fmt.Println(email, password)
|
|
@@ -142,6 +161,10 @@ func confirmClientInformation(w http.ResponseWriter, r *http.Request) (string, s
|
|
return DBClientSecret, DBDomain, DBServiceName, DBServiceImage, responseType, clientID, redirectURI, scope, state, nonce
|
|
return DBClientSecret, DBDomain, DBServiceName, DBServiceImage, responseType, clientID, redirectURI, scope, state, nonce
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func confirmUserInfo(w http.ResponseWriter, r *http.Request, username string) {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
func getGET(w http.ResponseWriter, r *http.Request, name string) string {
|
|
func getGET(w http.ResponseWriter, r *http.Request, name string) string {
|
|
response, ok := r.URL.Query()[name]
|
|
response, ok := r.URL.Query()[name]
|
|
if !ok || len(response[0]) < 1 {
|
|
if !ok || len(response[0]) < 1 {
|