|
@@ -165,11 +165,13 @@ func (l *loginAuth) getSessionAuth(ctx context.Context, phone string) (*redis_mo
|
|
}
|
|
}
|
|
return auth, nil
|
|
return auth, nil
|
|
}
|
|
}
|
|
|
|
+
|
|
func (l *loginAuth) getToken(ctx context.Context, phone string) string {
|
|
func (l *loginAuth) getToken(ctx context.Context, phone string) string {
|
|
timeSeed := strconv.FormatInt(time.Now().Unix(), 10)
|
|
timeSeed := strconv.FormatInt(time.Now().Unix(), 10)
|
|
token := phone + "." + timeSeed + "." + util.MD5(phone, timeSeed, consts.AuthSalt)
|
|
token := phone + "." + timeSeed + "." + util.MD5(phone, timeSeed, consts.AuthSalt)
|
|
return token
|
|
return token
|
|
}
|
|
}
|
|
|
|
+
|
|
func (l *loginAuth) parseToken(ctx context.Context, token string) (string, error) {
|
|
func (l *loginAuth) parseToken(ctx context.Context, token string) (string, error) {
|
|
parts := strings.Split(token, ".")
|
|
parts := strings.Split(token, ".")
|
|
if len(parts) == 3 {
|
|
if len(parts) == 3 {
|
|
@@ -181,9 +183,11 @@ func (l *loginAuth) parseToken(ctx context.Context, token string) (string, error
|
|
}
|
|
}
|
|
return "", errors.New("token invalid")
|
|
return "", errors.New("token invalid")
|
|
}
|
|
}
|
|
|
|
+
|
|
func (l *loginAuth) encryptPassword(password string) string {
|
|
func (l *loginAuth) encryptPassword(password string) string {
|
|
return util.MD5(password)
|
|
return util.MD5(password)
|
|
}
|
|
}
|
|
|
|
+
|
|
func (l *loginAuth) getRedisKey(key string) string {
|
|
func (l *loginAuth) getRedisKey(key string) string {
|
|
return fmt.Sprintf("%s%s", consts.SessionRedisPrefix, key)
|
|
return fmt.Sprintf("%s%s", consts.SessionRedisPrefix, key)
|
|
}
|
|
}
|