Customize auth user table
The authentication user table of the framework is the most basic information, if you need to customize a lot of extra information, such as mobile phone/IP/gender, etc. You can custom an authentication user table.
First, you need to prepare your own user table. Such as: goadmin_super_manager。And then modify configuration item auth_user_table in the global configuration. Then generate data model file, overwriting the official user table model file:
Note: the user table fields remain with the official line, then on the basis of the official user table field extension.
1
import (
2
...
3
"github.com/GoAdminGroup/go-admin/engine"
4
...
5
)
6
7
func main() {
8
9
...
10
11
eng := engine.Default()
12
13
cfg := config.Config{
14
...
15
AuthUserTable: "goadmin_super_manager",
16
...
17
}
18
19
if err := eng.AddConfig(cfg).
20
// Super administrator access, data model logic can refer to the official documents:https://github.com/GoAdminGroup/go-admin/blob/master/plugins/admin/modules/table/generators.go#L40
21
AddGenerator("manager", GetGoAdminSuperManager).
22
// Ordinary users to access
23
AddGenerator("normal_manager", GetGoAdminSuperNormalManager).
24
...
25
Use(r); err != nil {
26
panic(err)
27
}
28
29
...
30
31
}
Copied!
Last modified 1yr ago
Copy link