自动注册工单系统账号

pull/665/head
LawyZHENG 2021-03-17 15:59:05 +08:00
parent 25c58d9988
commit 545537ecf1
3 changed files with 34 additions and 26 deletions

View File

@ -4,11 +4,12 @@ package conf
import (
"strings"
"github.com/astaxie/beego"
"strconv"
"path/filepath"
"os"
"fmt"
"os"
"path/filepath"
"strconv"
"github.com/astaxie/beego"
)
// 登录用户的Session名
@ -19,7 +20,8 @@ const CaptchaSessionName = "__captcha__"
const RegexpEmail = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
//允许用户名中出现点号
const RegexpAccount = `^[a-zA-Z][a-zA-Z0-9\.-]{2,50}$`
// const RegexpAccount = `^[a-zA-Z][a-zA-Z0-9\.-]{2,50}$`
const RegexpAccount = `[a-zA-Z0-9\.-]{2,50}$`
// PageSize 默认分页条数.
const PageSize = 10
@ -158,7 +160,7 @@ func GetExportProcessNum() int {
if exportProcessNum <= 0 || exportProcessNum > 4 {
exportProcessNum = 1
}
return exportProcessNum;
return exportProcessNum
}
//导出项目队列的并发数量
@ -168,7 +170,7 @@ func GetExportLimitNum() int {
if exportLimitNum < 0 {
exportLimitNum = 1
}
return exportLimitNum;
return exportLimitNum
}
//等待导出队列的长度
@ -210,7 +212,7 @@ func IsAllowUploadFileExt(ext string) bool {
//重写生成URL的方法加上完整的域名
func URLFor(endpoint string, values ...interface{}) string {
baseUrl := beego.AppConfig.DefaultString("baseurl", "")
pathUrl := beego.URLFor(endpoint, values ...)
pathUrl := beego.URLFor(endpoint, values...)
if baseUrl == "" {
baseUrl = BaseUrl
@ -224,12 +226,12 @@ func URLFor(endpoint string, values ...interface{}) string {
if !strings.HasPrefix(pathUrl, "/") && !strings.HasSuffix(baseUrl, "/") {
return baseUrl + "/" + pathUrl
}
return baseUrl + beego.URLFor(endpoint, values ...)
return baseUrl + beego.URLFor(endpoint, values...)
}
func URLForNotHost(endpoint string,values ...interface{}) string {
func URLForNotHost(endpoint string, values ...interface{}) string {
baseUrl := beego.AppConfig.DefaultString("baseurl", "")
pathUrl := beego.URLFor(endpoint, values ...)
pathUrl := beego.URLFor(endpoint, values...)
if baseUrl == "" {
baseUrl = "/"
@ -243,7 +245,7 @@ func URLForNotHost(endpoint string,values ...interface{}) string {
if !strings.HasPrefix(pathUrl, "/") && !strings.HasSuffix(baseUrl, "/") {
return baseUrl + "/" + pathUrl
}
return baseUrl + beego.URLFor(endpoint, values ...)
return baseUrl + beego.URLFor(endpoint, values...)
}
func URLForWithCdnImage(p string) string {

View File

@ -3,6 +3,17 @@ package controllers
import (
"encoding/json"
"fmt"
"html/template"
"image/png"
"net/http"
"net/url"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
@ -16,16 +27,6 @@ import (
"github.com/lifei6671/mindoc/utils/gopool"
"github.com/lifei6671/mindoc/utils/pagination"
"gopkg.in/russross/blackfriday.v2"
"html/template"
"image/png"
"net/http"
"net/url"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
)
// DocumentController struct
@ -246,7 +247,7 @@ func (c *DocumentController) Edit() {
if conf.GetUploadFileSize() > 0 {
c.Data["UploadFileSize"] = conf.GetUploadFileSize()
} else {
c.Data["UploadFileSize"] = "undefined";
c.Data["UploadFileSize"] = "undefined"
}
}
@ -1257,7 +1258,7 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu
if book.BookPassword != "" {
//判断已存在的密码是否正确
if password, ok := c.GetSession(identify).(string); !ok || !strings.EqualFold(password, book.BookPassword) {
body, err := c.ExecuteViewPathTemplate("document/document_password.tpl", map[string]string{"Identify": book.Identify});
body, err := c.ExecuteViewPathTemplate("document/document_password.tpl", map[string]string{"Identify": book.Identify})
if err != nil {
beego.Error("显示密码页面失败 ->", err)
}

View File

@ -17,12 +17,13 @@ import (
"gopkg.in/ldap.v2"
"math"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
"github.com/lifei6671/mindoc/conf"
"github.com/lifei6671/mindoc/utils"
"math"
)
type Member struct {
@ -167,13 +168,17 @@ func (m *Member) httpLogin(account, password string) (*Member, error) {
return nil, ErrMemberAuthMethodInvalid
}
tmpH := md5.New()
tmpH.Write([]byte(password))
password = strings.ToUpper(hex.EncodeToString(tmpH.Sum(nil)))
val := url.Values{
"account": []string{account},
"password": []string{password},
"time": []string{strconv.FormatInt(time.Now().Unix(), 10)},
}
h := md5.New()
h.Write([]byte(val.Encode() + beego.AppConfig.DefaultString("http_login_secret","")))
h.Write([]byte(val.Encode() + beego.AppConfig.DefaultString("http_login_secret", "")))
val.Add("sn", hex.EncodeToString(h.Sum(nil)))