Selaa lähdekoodia

取消临时登录接口

LawyZHENG 4 vuotta sitten
vanhempi
sitoutus
d4f743b7f2
1 muutettua tiedostoa jossa 0 lisäystä ja 65 poistoa
  1. 0 65
      controllers/AccountController.go

+ 0 - 65
controllers/AccountController.go

@@ -1,10 +1,6 @@
 package controllers
 
 import (
-	"crypto/hmac"
-	"crypto/sha1"
-	"encoding/base64"
-	"fmt"
 	"net/url"
 	"regexp"
 	"strings"
@@ -181,67 +177,6 @@ func (c *AccountController) DingTalkLogin() {
 	c.JsonResult(0, "ok", username)
 }
 
-// 临时登录
-func (c *AccountController) TmpLogin() {
-	if c.Member != nil {
-		c.Redirect(conf.URLFor("HomeController.Index"), 302)
-	}
-
-	tmpToken := c.GetString("tmpToken")
-	if tmpToken == "" {
-		c.Redirect(conf.URLFor("AccountController.Login"), 302)
-	}
-
-	tmp, err := base64.URLEncoding.DecodeString(tmpToken)
-	if err != nil {
-		c.Redirect(conf.URLFor("AccountController.Login"), 302)
-	}
-
-	tmpToken = string(tmp)
-	var remember CookieRemember
-	// 如果 Cookie 中存在登录信息
-	cookie, ok := c.GetSecureCookie(conf.GetAppKey(), "login")
-	if !ok {
-		cookie, ok = parseHelper(tmpToken)
-	}
-
-	// 解析用户,并登录
-	if ok {
-		if err := utils.Decode(cookie, &remember); err == nil {
-			if member, err := models.NewMember().Find(remember.MemberId); err == nil {
-				c.SetMember(*member)
-				c.LoggedIn(false)
-				c.StopRun()
-			}
-		}
-	}
-	c.Redirect(conf.URLFor("AccountController.Login"), 302)
-
-}
-
-func parseHelper(value string) (string, bool) {
-
-	parts := strings.SplitN(value, "|", 3)
-
-	if len(parts) != 3 {
-		return "", false
-	}
-
-	vs := parts[0]
-	timestamp := parts[1]
-	sig := parts[2]
-
-	h := hmac.New(sha1.New, []byte(conf.GetAppKey()))
-	fmt.Fprintf(h, "%s%s", vs, timestamp)
-
-	if fmt.Sprintf("%02x", h.Sum(nil)) != sig {
-		return "", false
-	}
-	res, _ := base64.URLEncoding.DecodeString(vs)
-	return string(res), true
-
-}
-
 // 登录成功后的操作,如重定向到原始请求页面
 func (c *AccountController) LoggedIn(isPost bool) interface{} {