代码拉取完成,页面将自动刷新
package database
import (
"github.com/webx-top/com"
"github.com/webx-top/echo"
"github.com/admpub/nging/application/library/dbmanager"
"github.com/admpub/nging/application/library/dbmanager/driver"
"github.com/admpub/nging/application/model"
)
func authentication(mgr dbmanager.Manager, accountID uint, m *model.DbAccount) (err error, succeed bool) {
ctx := mgr.Context()
auth := mgr.Account()
if accountID > 0 {
auth.Driver = m.Engine
auth.Username = m.User
auth.Password = m.Password
auth.Host = m.Host
auth.Db = m.Name
auth.AccountID = m.Id
auth.AccountTitle = m.Title
if len(m.Options) > 0 {
options := echo.H{}
com.JSONDecode(com.Str2bytes(m.Options), &options)
auth.Charset = options.String(`charset`)
}
if len(auth.Charset) == 0 {
auth.Charset = `utf8mb4`
}
err = mgr.Run(auth.Driver, `login`)
succeed = err == nil
return
}
if accounts, exists := ctx.Session().Get(`dbAccounts`).(driver.AuthAccounts); exists {
ctx.Internal().Set(`dbAccounts`, &accounts)
key := driver.GenKey(auth.Driver, auth.Username, auth.Host, auth.Db, accountID)
data := accounts.Get(key)
if data == nil {
return
}
auth.CopyFrom(data)
err = mgr.Run(auth.Driver, `login`)
succeed = err == nil
return
}
return
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。