You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1021 B
38 lines
1021 B
package controller
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"github.com/taoshihan1991/imaptool/tools"
|
|
"html/template"
|
|
"net/http"
|
|
)
|
|
//登陆界面
|
|
func ActionLogin(w http.ResponseWriter, r *http.Request){
|
|
html := tools.FileGetContent("html/login.html")
|
|
t, _ := template.New("login").Parse(html)
|
|
t.Execute(w, nil)
|
|
}
|
|
//验证接口
|
|
func LoginCheck(w http.ResponseWriter, r *http.Request) {
|
|
email := r.PostFormValue("email")
|
|
server := r.PostFormValue("server")
|
|
password := r.PostFormValue("password")
|
|
msg, _ := json.Marshal(tools.JsonResult{Code: 400, Msg: "验证失败"})
|
|
|
|
w.Header().Set("content-type", "text/json;charset=utf-8;")
|
|
if email != "" && server != "" && password != "" {
|
|
res := tools.CheckEmailPassword(server, email, password)
|
|
if res {
|
|
msg, _ = json.Marshal(tools.JsonResult{Code: 200, Msg: "验证成功,正在跳转..."})
|
|
auth := fmt.Sprintf("%s|%s|%s", server, email, password)
|
|
tools.SetCookie("auth", auth, &w)
|
|
w.Write(msg)
|
|
} else {
|
|
w.Write(msg)
|
|
}
|
|
} else {
|
|
w.Write(msg)
|
|
}
|
|
}
|