Documentation ¶
Index ¶
- Constants
- Variables
- func ABTestClick(r *http.Request, group string)
- func AdminPage(order string, asc bool, offset int, limit int, a interface{}, ...) (err error)
- func All(a interface{}) (err error)
- func Avg(a interface{}, column string, query interface{}, args ...interface{}) float64
- func AvgTable(table string, column string, query interface{}, args ...interface{}) float64
- func CORSHandler(f func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request)
- func CheckCSRF(r *http.Request) bool
- func CheckRateLimit(r *http.Request) bool
- func ClearDB()
- func Count(a interface{}, query interface{}, args ...interface{}) int
- func CountTable(table string, query interface{}, args ...interface{}) int
- func Delete(a interface{}) (err error)
- func DeleteList(a interface{}, query interface{}, args ...interface{}) (err error)
- func Filter(a interface{}, query interface{}, args ...interface{}) (err error)
- func FilterBuilder(params map[string]interface{}) (query string, args []interface{})
- func FilterList(s *ModelSchema, order string, asc bool, offset int, limit int, a interface{}, ...) (err error)
- func FilterSorted(order string, asc bool, a interface{}, query interface{}, args ...interface{}) (err error)
- func FilterSortedTable(table string, order string, asc bool, a interface{}, query interface{}, ...) (err error)
- func FilterSortedValue(table string, column string, order string, asc bool, a interface{}, ...) (err error)
- func FilterTable(table string, a interface{}, query interface{}, args ...interface{}) (err error)
- func GenerateBase32(length int) string
- func GenerateBase64(length int) string
- func GenerateOpenAPISchema()
- func Get(a interface{}, query interface{}, args ...interface{}) (err error)
- func GetABTest(r *http.Request, a interface{}, query interface{}, args ...interface{}) (err error)
- func GetDB() *gorm.DB
- func GetFieldsAPI(w http.ResponseWriter, r *http.Request, session *Session)
- func GetForm(a interface{}, s *ModelSchema, query interface{}, args ...interface{}) (err error)
- func GetHostName(r *http.Request) string
- func GetID(m reflect.Value) uint
- func GetModelsAPI(w http.ResponseWriter, r *http.Request, session *Session)
- func GetRemoteIP(r *http.Request) string
- func GetSchema(r *http.Request) string
- func GetSetting(code string) interface{}
- func GetSorted(order string, asc bool, a interface{}, query interface{}, args ...interface{}) (err error)
- func GetSortedTable(table string, order string, asc bool, a interface{}, query interface{}, ...) (err error)
- func GetString(a interface{}) string
- func GetStringer(a interface{}, query interface{}, args ...interface{}) (err error)
- func GetTable(table string, a interface{}, query interface{}, args ...interface{}) (err error)
- func GetValueSorted(table string, column string, order string, asc bool, a interface{}, ...) (err error)
- func Handler(f func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)
- func IncrementMetric(name string)
- func JSONMarshal(v interface{}, safeEncoding bool) ([]byte, error)
- func Logout(r *http.Request)
- func Max(a interface{}, column string, query interface{}, args ...interface{}) float64
- func MaxTable(table string, column string, query interface{}, args ...interface{}) float64
- func Min(a interface{}, column string, query interface{}, args ...interface{}) float64
- func MinTable(table string, column string, query interface{}, args ...interface{}) float64
- func NewMetric(name string, template string) error
- func NewModel(modelName string, pointer bool) (reflect.Value, bool)
- func NewModelArray(modelName string, pointer bool) (reflect.Value, bool)
- func Preload(a interface{}, preload ...string) (err error)
- func Register(m ...interface{})
- func RegisterInlines(model interface{}, fk map[string]string)
- func RegisterTrailChan(c chan string)
- func RenderHTML(w http.ResponseWriter, r *http.Request, path string, data interface{}, ...)
- func RenderMultiHTML(w http.ResponseWriter, r *http.Request, path []string, data interface{}, ...)
- func RespondAndLogError(w http.ResponseWriter, r *http.Request, code int, errMsg string, err error)
- func ReturnJSON(w http.ResponseWriter, r *http.Request, v interface{})
- func SQLInjection(r *http.Request, key, value string) bool
- func Save(a interface{}) (err error)
- func SendEmail(to, cc, bcc []string, subject, body string, attachments ...string) (err error)
- func SetCookieTimeout()
- func SetDB(mockDB *gorm.DB)
- func SetMetric(name string, value float64)
- func SetSessionCookie(w http.ResponseWriter, r *http.Request, s *Session) string
- func StartSecureServer(certFile, keyFile string)
- func StartServer()
- func StaticHandler(w http.ResponseWriter, r *http.Request)
- func Std(a interface{}, column string, query interface{}, args ...interface{}) float64
- func StdTable(table string, column string, query interface{}, args ...interface{}) float64
- func Sum(a interface{}, column string, query interface{}, args ...interface{}) float64
- func SumTable(table string, column string, query interface{}, args ...interface{}) float64
- func Syslogf(level int, msg string, a ...interface{})
- func Tf(path string, lang string, term string, args ...interface{}) string
- func TimeMetric(name string, div float64, f func())
- func Trail(level int, msg interface{}, i ...interface{})
- func Translate(raw string, lang string, args ...bool) string
- func TranslateSchema(s *ModelSchema, lang string)
- func Update(a interface{}, fieldName string, value interface{}, query string, ...) (err error)
- func UploadImageHandler(w http.ResponseWriter, r *http.Request, session *Session)
- func ValidateIP(r *http.Request, allow string, block string) bool
- type ABTest
- type ABTestType
- type ABTestValue
- type APIDisabledAdder
- type APIDisabledDeleter
- type APIDisabledEditor
- type APIDisabledReader
- type APIDisabledSchemer
- type APILogAdder
- type APILogDeleter
- type APILogEditor
- type APILogReader
- type APILogSchemer
- type APIPostQueryAdder
- type APIPostQueryDeleter
- type APIPostQueryEditor
- type APIPostQueryReader
- type APIPostQuerySchemer
- type APIPreQueryAdder
- type APIPreQueryDeleter
- type APIPreQueryEditor
- type APIPreQueryReader
- type APIPreQuerySchemer
- type APIPublicAdder
- type APIPublicDeleter
- type APIPublicEditor
- type APIPublicReader
- type APIPublicSchemer
- type Action
- func (a Action) Added() Action
- func (a Action) Custom() Action
- func (a Action) Deleted() Action
- func (a Action) GetSchema() Action
- func (a Action) LoginDenied() Action
- func (a Action) LoginSuccessful() Action
- func (a Action) Logout() Action
- func (a Action) Modified() Action
- func (a Action) PasswordResetDenied() Action
- func (a Action) PasswordResetRequest() Action
- func (a Action) PasswordResetSuccessful() Action
- func (a Action) Read() Action
- type Approval
- type ApprovalAction
- type AutoMigrater
- type CKey
- type Choice
- type DBSettings
- type DashboardMenu
- type DataType
- type F
- type FieldList
- type FieldType
- func (FieldType) Boolean() FieldType
- func (FieldType) Code() FieldType
- func (FieldType) DateTime() FieldType
- func (FieldType) DateTimePtr() FieldType
- func (FieldType) Email() FieldType
- func (FieldType) File() FieldType
- func (FieldType) Float() FieldType
- func (FieldType) ForeignKey() FieldType
- func (FieldType) HTML() FieldType
- func (FieldType) Image() FieldType
- func (FieldType) Int() FieldType
- func (FieldType) Link() FieldType
- func (FieldType) M2M() FieldType
- func (FieldType) Money() FieldType
- func (FieldType) Multilingual() FieldType
- func (FieldType) Password() FieldType
- func (FieldType) ProgressBar() FieldType
- func (FieldType) StaticList() FieldType
- func (FieldType) String() FieldType
- type GetImageSizer
- type GroupPermission
- type HideInDashboarder
- type Language
- type Log
- func (Log) HideInDashboard() bool
- func (l *Log) ParseRecord(a reflect.Value, modelName string, ID uint, user *User, action Action, ...) (err error)
- func (l *Log) PasswordReset(user string, action Action, r *http.Request) (err error)
- func (l *Log) Save()
- func (l *Log) SignIn(user string, action Action, r *http.Request) (err error)
- func (l Log) String() string
- type Model
- type ModelList
- type ModelSchema
- type SchemaCategory
- type Session
- type Setting
- type SettingCategory
- type User
- func (u *User) GeneratePasswordResetLink(r *http.Request, link string) (string, error)
- func (u *User) GeneratePasswordResetOTP() string
- func (u *User) GetAccess(modelName string) UserPermission
- func (u *User) GetActiveSession() *Session
- func (u *User) GetDashboardMenu() (menus []DashboardMenu)
- func (u *User) GetOTP() string
- func (u *User) HasAccess(modelName string) UserPermission
- func (u *User) Login(pass string, otp string) *Session
- func (u *User) Save()
- func (u User) String() string
- func (u User) Validate() (ret map[string]string)
- func (u *User) VerifyOTP(pass string) bool
- func (u *User) VerifyOTPAtPasswordReset(pass string) bool
- type UserGroup
- type UserPermission
Constants ¶
const ( NONE = 10 DEBUG = 0 WORKING = 1 INFO = 2 OK = 3 WARNING = 4 ERROR = 5 CRITICAL = 6 ALERT = 7 EMERGENCY = 8 )
Reporting Levels
const Version = "0.10.0"
Version number as per Semantic Versioning 2.0.0 (semver.org)
const VersionCodeName = "Housefly"
VersionCodeName is the cool name we give to versions with significant changes. This name should always be a bug's name starting from A-Z them revolving back. This started at version 0.5.0 (Atlas Moth) 0.6.0 Beetle 0.7.0 Catterpiller 0.8.0 Dragonfly 0.9.0 Gnat 0.10.0 Gnat
Variables ¶
var APIDisabledAdd = false
APIDisabledAdd controls the data API's disabled for add commands.
var APIDisabledDelete = false
APIDisabledDelete controls the data API's disabled for delete commands.
var APIDisabledEdit = false
APIDisabledEdit controls the data API's disabled for edit commands.
var APIDisabledRead = false
APIDisabledRead controls the data API’s disabled for add commands.
var APIDisabledSchema = false
APIDisabledSchema controls the data API's disabled for schema commands.
var APILogAdd = true
APILogAdd controls the data API's logging for add commands.
var APILogDelete = true
APILogDelete controls the data API's logging for delete commands.
var APILogEdit = true
APILogEdit controls the data API's logging for edit commands.
var APILogRead = false
APILogRead controls the data API's logging for read commands.
var APILogSchema = true
APILogSchema controls the data API's logging for schema commands.
var APIPostQueryAdd = false
APIPostQueryAdd controls the data API's post query for add commands.
var APIPostQueryAddHandler func(http.ResponseWriter, *http.Request, map[string]interface{}) bool
APIPostQueryAddHandler is a function that runs after all dAPI add requests
var APIPostQueryDelete = false
APIPostQueryDelete controls the data API's post query for delete commands.
var APIPostQueryDeleteHandler func(http.ResponseWriter, *http.Request, map[string]interface{}) bool
APIPostQueryDeleteHandler is a function that runs after all dAPI delete requests
var APIPostQueryEdit = false
APIPostQueryEdit controls the data API's post query for edit commands.
var APIPostQueryEditHandler func(http.ResponseWriter, *http.Request, map[string]interface{}) bool
APIPostQueryEditHandler is a function that runs after all dAPI edit requests
var APIPostQueryRead = false
APIPostQueryRead controls the data API’s post query for add commands.
var APIPostQueryReadHandler func(http.ResponseWriter, *http.Request, map[string]interface{}) bool
APIPostQueryReadHandler is a function that runs after all dAPI read requests
var APIPostQuerySchema = false
APIPostQuerySchema controls the data API's post query for schema commands.
var APIPreQueryAdd = false
APIPreQueryAdd controls the data API's pre query for add commands.
var APIPreQueryAddHandler func(http.ResponseWriter, *http.Request) bool
APIPreQueryAddHandler is a function that runs before all dAPI add requests
var APIPreQueryDelete = false
APIPreQueryDelete controls the data API's pre query for delete commands.
var APIPreQueryDeleteHandler func(http.ResponseWriter, *http.Request) bool
APIPreQueryDeleteHandler is a function that runs before all dAPI delete requests
var APIPreQueryEdit = false
APIPreQueryEdit controls the data API's pre query for edit commands.
var APIPreQueryEditHandler func(http.ResponseWriter, *http.Request) bool
APIPreQueryEditHandler is a function that runs before all dAPI edit requests
var APIPreQueryRead = false
APIPreQueryRead controls the data API’s pre query for add commands.
var APIPreQueryReadHandler func(http.ResponseWriter, *http.Request) bool
APIPreQueryReadHandler is a function that runs before all dAPI read requests
var APIPreQuerySchema = false
APIPreQuerySchema controls the data API's pre query for schema commands.
var APIPublicAdd = false
APIPublicAdd controls the data API's public for add commands.
var APIPublicDelete = false
APIPublicDelete controls the data API's public for delete commands.
var APIPublicEdit = false
APIPublicEdit controls the data API's public for edit commands.
var APIPublicRead = false
APIPublicRead controls the data API’s public for add commands.
var APIPublicSchema = false
APIPublicSchema controls the data API's public for schema commands.
var AcceptedJWTIssuers = []string{}
AcceptedJWTIssuers is a list of accepted JWT issuers. By default the local JWTIssuer is accepted. To accept other issuers, add them to this list
var ActiveLangs []Language
Global active languages
var AllowDAPISignup = false
AllowDAPISignup allows unauthenticated users to sign up
var AllowedCORSOrigins []string
AllowedCORSOrigins is a list of allowed CORS origins
var AllowedHosts = "0.0.0.0,127.0.0.1,localhost,::1"
AllowedHosts is a comma separated list of allowed hosts for the server to work. The default value is only for development. Production domain should be added before deployment
var AllowedIPs = "*"
AllowedIPs is a list of allowed IPs to access uAdmin interfrace in one of the following formats: - "*" = Allow all - "" = Allow none - "192.168.1.1" Only allow this IP - "192.168.1.0/24" Allow all IPs from 192.168.1.1 to 192.168.1.254 You can also create a list of the above formats using comma to separate them. For example: "192.168.1.1,192.168.1.2,192.168.0.0/24"
var ApprovalHandleFunc func(*Approval) bool
ApprovalHandleFunc is a function that could be called during the save process of each approval
var BindIP = ""
BindIP is the IP the application listens to.
var BlockedIPs = ""
BlockedIPs is a list of blocked IPs from accessing uAdmin interfrace in one of the following formats: - "*" = Block all - "" = Block none - "192.168.1.1" Only block this IP - "192.168.1.0/24" Block all IPs from 192.168.1.1 to 192.168.1.254 You can also create a list of the above formats using comma to separate them. For example: "192.168.1.1,192.168.1.2,192.168.0.0/24"
var CSRFCacheCleanupInterval = 24
CSRFCacheCleanupInterval is the number of hours to clear expired cache
var CSRFCacheDefaultExpiration = 30
CSRFCacheDefaultExpiration is the number of minutes for token to expire
var CachePermissions = true
CachePermissions allows uAdmin to store permissions data in memory
var CacheSessions = true
CacheSessions allows uAdmin to store sessions data in memory
var CacheTranslation = false
CacheTranslation allows a translation to store data in a cache memory.
var CompressJSON = false
CompressJSON is a variable that allows the user to reduce the size of JSON responses
var CookieTimeout = -1
CookieTimeout is the timeout of a login cookie in seconds. If the value is -1, then the session cookie will not have an expiry date.
var CustomDAPIHeaders = map[string]string{}
CustomDAPIHeaders are extra handlers that would be added to dAPI responses
var CustomDAPILoginHandler func(*http.Request, *User, map[string]interface{}) map[string]interface{}
CustomDAPILoginHandler is a function that can provide extra information in the login return
var CustomEmailHandler func(to, cc, bcc *[]string, subject, body *string, attachments ...*string) (bool, error)
CustomEmailHandler allows to customize or even override the default email sending method. The return of of the function is a boolean and an error. All parameters are of pointers to allow customization of the parameters that will be passed to the default email sender.
- The boolean will determine whether to proceed or not. If true, the process will proceed with the default method of sending the email
- The error will be reported to Trail as type uadmin.ERROR
var CustomJWT func(r *http.Request, s *Session, payload map[string]interface{}) map[string]interface{}
var CustomOpenAPI func(*openapi.Schema)
CustomOpenAPI is a handler to be called to customize OpenAPI schema Use of OpenAPI schema generation is under development and should not be used in production
var CustomOpenAPIJSON func([]byte) []byte
CustomOpenAPIJSON is a handler to be called to customize OpenAPI schema JSON output Use of OpenAPI schema generation is under development and should not be used in production
var CustomResetPasswordLink = ""
CustomResetPasswordLink is the link sent to the user's email to reset their password the string may include the following place holder: "{SCHEMA}://{HOST}/resetpassword?u={USER_ID}&key={OTP}"
var CustomTranslation = []string{
"uadmin/system",
}
CustomTranslation is where you can register custom translation files. To register a custom translation file, always assign it with it's key in the this format "category/name". For example:
uadmin.CustomTranslation = append(uadmin.CustomTranslation, "ui/billing")
This will register the file and you will be able to use it if `uadmin.Tf`. By default there is only one registered custom translation which is "uadmin/system".
var CustomizeJSON func(http.ResponseWriter, *http.Request, interface{}, []byte) []byte
CustomizeJSON is a function to allow customization of JSON returns
var DAPISignupActive = true
DAPISignupActive controls if new signed up users are activate automatically
var DAPISignupAllowRemote = true
DAPISignupAllowRemote controls if new signed up users are can login over the internet
var DAPISignupGroupID = 0
DAPISignupGroupID is the default user group id new users get when they sign up to leave new signed up users without a group, use value 0 for this variable
var DebugDB = false
DebugDB prints all SQL statements going to DB.
var DefaultMediaPermission = os.FileMode(0644)
DefaultMediaPermission is the default permission applied to to files uploaded to the system
var DefaultModelLoad interface{} = nil
Model will be loaded on Dashboard on start page
var DisableAdminUI = false
DisableAdminUI disables access to the UI and all related APIs
var DisableDAPIAuth = true
DisableDAPIAuth enables or disables access to dAPI auth API
var EmailFrom string
EmailFrom identifies where the email is coming from.
var EmailPassword string
EmailPassword sets the password of an email.
var EmailSMTPServer string
EmailSMTPServer sets the name of the SMTP Server in an email.
var EmailSMTPServerPort int
EmailSMTPServerPort sets the port number of an SMTP Server in an email.
var EmailUsername string
EmailUsername sets the username of an email.
var EnableDAPICORS bool
EnableDAPICORS controller whether dAPI is uses CORS protocol to allow cross-origan requests
var EncryptKey = []byte{}
EncryptKey is a key for encryption and decryption of data in the DB.
var ErrorHandleFunc func(int, string, string)
ErrorHandleFunc is a function that will be called everytime Trail is called. It receives one parameter for error level, one for error message and one for runtime stack trace
var FavIcon = "/static/uadmin/favicon.ico"
FavIcon is the fav icon that shows on uAdmin UI
var FullMediaURL = false
FullMediaURL allows uAdmin to send you full path URL instead on relative path for dAPI read requests
var HTTPLogFormat = "%a %>s %B %U %D"
HTTPLogFormat is the format used to log HTTP access %a: Client IP address %A: Server hostname/IP %{local}p: Server port %U: Path %c: All cookies %{NAME}c: Cookie named 'NAME' %{GET}f: GET request parameters %{POST}f: POST request parameters %B: Response length %>s: Response code %D: Time taken in microseconds %T: Time taken in seconds %I: Request length
var JWT = ""
JWT secret for signing tokens
var JWTIssuer = ""
jwtIssuer is a URL to identify the application issuing JWT tokens. If left empty, a partial hash of JWT will be assigned. This is also used to identify the as JWT audience.
var LogAdd = true
LogAdd adds a log when a record is added.
var LogDelete = true
LogDelete adds a log when a record is deleted.
var LogEdit = true
LogEdit adds a log when a record is edited.
var LogHTTPRequests = true
LogHTTPRequests logs http requests to syslog
var LogRead = false
LogRead adds a log when a record is read.
var LogTrail = false
LogTrail stores Trail logs to syslog
var Logo = "/static/uadmin/logo.png"
Logo is the main logo that shows on uAdmin UI
var MaskPasswordInAPI = true
MaskPasswordInAPI will replace any password fields with an asterisk mask
var MaxImageHeight = 600
MaxImageHeight sets the maximum height of an image.
var MaxImageWidth = 800
MaxImageWidth sets the maximum width of an image.
var MaxUploadFileSize = int64(25 * 1024 * 1024)
MaxUploadFileSize is the maximum upload file size in bytes.
var OTPAlgorithm = "sha1"
OTPAlgorithm is the hashing algorithm of OTP.
var OTPDigits = 6
OTPDigits is the number of digits for the OTP.
var OTPPeriod = uint(30)
OTPPeriod is the number of seconds for the OTP to change.
var OTPSkew = uint(5)
OTPSkew is the number of minutes to search around the OTP.
var OptimizeSQLQuery = false
OptimizeSQLQuery selects columns during rendering a form a list to visible fields. This means during the filtering of a form the select statement will not include any field with `hidden` tag. For list it will not select any field with `list_exclude`
var PageLength = 100
PageLength is the list view max number of records.
var PasswordAttempts = 5
PasswordAttempts is the maximum number of invalid password attempts before the IP address is blocked for some time from using the system
var PasswordTimeout = 15
PasswordTimeout is the amount of time in minutes the IP will be blocked for after reaching the the maximum invalid password attempts
var Port = 8080
Port is the port used for http or https server.
var PostUploadHandler func(filePath string, modelName string, f *F) string
PreLoginHandler is a function that runs after all dAPI delete requests
var PreLoginHandler func(r *http.Request, username string, password string)
PreLoginHandler is a function that runs after all dAPI delete requests
var PublicMedia = false
PublicMedia allows public access to media handler without authentication.
var RateLimit int64 = 3
RateLimit is the maximum number of requests/second for any unique IP
var RateLimitBlockedMinutes = 10
RateLimitBlockedMinutes is the number of minutes to block a user
var RateLimitBurst int64 = 3
RateLimitBurst is the maximum number of requests for an idle user
var RateLimitCacheCapacity = 1024
RateLimitCacheCapacity is the maximum number users in cache
var RateLimitEventFrequency = 0.5
RateLimitEventFrequency defines the maximum frequency of some events and represented as number of events per second. A zero Limit allows no events
var RateLimitTokenNumber = 10
RateLimitTokenNumber is the number of tokens
var RemoveZeroValueJSON = false
CompressJSON is a variable that allows the user to reduce the size of JSON responses
var ReportTimeStamp = false
ReportTimeStamp set this to true to have a time stamp in your logs.
var ReportingLevel = DEBUG
ReportingLevel is the standard reporting level.
var ResetPasswordMessage = `` /* 329-byte string literal not displayed */
ResetPasswordMessage is a message that can be sent to the user email when a password reset request sends an email. This message may include the following place holders: {NAME}: user real name {WEBSITE}: website name {URL}: link to the password reset page
var RestrictSessionIP = false
RestrictSessionIP is to block access of a user if their IP changes from their original IP during login
var RetainMediaVersions = true
RetainMediaVersions is to allow the system to keep files uploaded even after they are changed. This allows the system to "Roll Back" to an older version of the file.
var RootURL = "/"
RootURL is where the listener is mapped to.
var Salt = ""
Salt is added to password hashing
var Schema map[string]ModelSchema
Schema is the global schema of the system.
var ServerReady = false
ServerReady is a variable that is set to true once the server is ready to use
var SignupValidationHandler func(user *User) error
SignupValidationHandler can be used to validate or customize new signed up users. Note that the password in the password field is passed in plain text. Do not plain text passwords anywhere.
var SiteName = "uAdmin"
SiteName is the name of the website that shows on title and dashboard.
var SystemMetrics = false
SystemMetrics enables uAdmin system metrics to be recorded
var Theme = "default"
Theme is the name of the theme used in uAdmin.
var TimeZone = "local"
TimeZone specifies the the default time zone for the system. Valid values include IANA Time Zones like America/New_York, Asia/Riyadh and UTC. To get local time zone use "local"
var TrailCacheSize = 65536
TrailCacheSize is the number of bytes to keep in memory of trail logs
var TrailLoggingLevel = INFO
TrailLoggingLevel is the minimum level to be logged into syslog
var UserMetrics = false
UserMetrics enables the user metrics to be recorded
Functions ¶
func ABTestClick ¶
ABTestClick is a function to register a click for an ABTest group
func AdminPage ¶
func AdminPage(order string, asc bool, offset int, limit int, a interface{}, query interface{}, args ...interface{}) (err error)
AdminPage !
func CORSHandler ¶
func CORSHandler(f func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request)
func CheckCSRF ¶
CheckCSRF checks if the request is a possible CSRF. CSRF or Cross-Site Request Forgery is a type of attack here a logged in user clicks on a link that is sent to a website where the user is already authenticated and has instructions for the website to change some state. A possible attack could delete user or system data, change it or add new data to the system. Anti-CSRF measures are implemented in all state chaning APIs and UI handler.
The way uAdmin implements CSRF is by checking for a request parameter GET or POST called `x-csrf-token`. The value of this parameter could be equal to the session key. You can get the session key from the session cookie or if you are using `uadmin.RenderHTML` or `uadmin.RenderHTMLMulti`, then you will find it in the context as `{{CSRF}}`. If you submitting a form you can add this value to a hidden input.
To implement anti CSRF protection in your own API:
func MyAPI(w http.ResponseWriter, r *http.Request) { if CheckCSRF(r) { uadmin.ReturnJSON(w, r, map[string]interface{}{ "status": "error", "err_msg": "The request does not have x-csrf-token", }) } // API code ... } http.HandleFunc("/myapi/", MyAPI)
If you you call this API:
http://0.0.0.0:8080/myapi/
It will return an error message and the system will create a CRITICAL level log with details about the possible attack. To make the request work, `x-csrf-token` parameter should be added.
http://0.0.0.0:8080/myapi/?x-csrf-token=MY_SESSION_KEY
Where you replace `MY_SESSION_KEY` with the session key.
func CheckRateLimit ¶
CheckRateLimit checks if the request has remaining quota or not. If it returns false, the IP in the request has exceeded their quota
func Count ¶
func Count(a interface{}, query interface{}, args ...interface{}) int
Count return the count of records in a table based on a filter
func CountTable ¶
CountTable return the count of records in a table based on a filter
func DeleteList ¶
func DeleteList(a interface{}, query interface{}, args ...interface{}) (err error)
DeleteList deletes multiple records from database
func Filter ¶
func Filter(a interface{}, query interface{}, args ...interface{}) (err error)
Filter fetches records from the database
func FilterBuilder ¶
FilterBuilder changes a map filter into a query
func FilterList ¶
func FilterList(s *ModelSchema, order string, asc bool, offset int, limit int, a interface{}, query interface{}, args ...interface{}) (err error)
FilterList fetches the all record from the database matching query and args where it selects only visible fields in the form based on given schema
func FilterSorted ¶
func FilterSorted(order string, asc bool, a interface{}, query interface{}, args ...interface{}) (err error)
Filter fetches records from the database
func FilterSortedTable ¶
func FilterSortedTable(table string, order string, asc bool, a interface{}, query interface{}, args ...interface{}) (err error)
Filter fetches records from the database
func FilterSortedValue ¶
func FilterSortedValue(table string, column string, order string, asc bool, a interface{}, query interface{}, args ...interface{}) (err error)
Filter fetches records from the database
func FilterTable ¶
Filter fetches records from the database
func GenerateBase32 ¶
GenerateBase32 generates a base32 string of length length
func GenerateBase64 ¶
GenerateBase64 generates a base64 string of length length
func GenerateOpenAPISchema ¶
func GenerateOpenAPISchema()
GenerateOpenAPISchema generates API schema for dAPI that is compatible with OpenAPI 3.1.0 Use of OpenAPI schema generation is under development and should not be used in production
func Get ¶
func Get(a interface{}, query interface{}, args ...interface{}) (err error)
Get fetches the first record from the database matching query and args
func GetFieldsAPI ¶
func GetFieldsAPI(w http.ResponseWriter, r *http.Request, session *Session)
GetFieldsAPI returns a list of fields in a model
func GetForm ¶
func GetForm(a interface{}, s *ModelSchema, query interface{}, args ...interface{}) (err error)
GetForm fetches the first record from the database matching query and args where it selects only visible fields in the form based on given schema
func GetHostName ¶
GetHostName is a function that returns the host name from a request
func GetModelsAPI ¶
func GetModelsAPI(w http.ResponseWriter, r *http.Request, session *Session)
GetModelsAPI returns a list of models
func GetRemoteIP ¶
GetRemoteIP is a function that returns the IP for a remote user from a request
func GetSetting ¶
func GetSetting(code string) interface{}
GetSetting return the value of a setting based on its code
func GetSorted ¶
func GetSorted(order string, asc bool, a interface{}, query interface{}, args ...interface{}) (err error)
Get fetches the first record from the database matching query and args with sorting
func GetSortedTable ¶
func GetSortedTable(table string, order string, asc bool, a interface{}, query interface{}, args ...interface{}) (err error)
Get fetches the first record from the database matching query and args with sorting
func GetString ¶
func GetString(a interface{}) string
GetString returns string representation on an instance of a model
func GetStringer ¶
func GetStringer(a interface{}, query interface{}, args ...interface{}) (err error)
GetStringer fetches the first record from the database matching query and args and get only fields tagged with `stringer` tag. If no field has `stringer` tag then it gets all the fields
func GetValueSorted ¶
func GetValueSorted(table string, column string, order string, asc bool, a interface{}, query interface{}, args ...interface{}) (err error)
Get fetches the first record from the database matching query and args with sorting
func Handler ¶
func Handler(f func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)
Handler is a function that takes an http handler function and returns an http handler function that has extra functionality including logging
func JSONMarshal ¶
JSONMarshal Generates JSON format from an object
func NewModelArray ¶
NewModelArray creates a new model from a model name
func Preload ¶
Preload fills the data from foreign keys into structs. You can pass in preload alist of fields to be preloaded. If nothing is passed, every foreign key is preloaded
func RegisterInlines ¶
RegisterInlines is a function to register a model as an inline for another model Parameters: ===========
model (struct instance): Is the model that you want to add inlines to. fk (map[interface{}]string): This is a map of the inlines to be added to the model. The map's key is the name of the model of the inline and the value of the map is the foreign key field's name. Example: ======== type Person struct { uadmin.Model Name string } type Card struct { uadmin.Model PersonID uint Person Person } func main() { ... uadmin.RegisterInlines(Person{}, map[string]string{ "Card": "PersonID", }) ... }
func RegisterTrailChan ¶
func RegisterTrailChan(c chan string)
func RenderHTML ¶
func RenderHTML(w http.ResponseWriter, r *http.Request, path string, data interface{}, funcs ...interface{})
RenderHTML creates a new template and applies a parsed template to the specified data object. For function, Tf is available by default and if you want to add functions to your template, just add them to funcs which will add them to the template with their original function names. If you added anonymous functions, they will be available in your templates as func1, func2 ...etc.
func RenderMultiHTML ¶
func RenderMultiHTML(w http.ResponseWriter, r *http.Request, path []string, data interface{}, funcs ...interface{})
RenderMultiHTML creates a new template and applies a parsed template to the specified data object. For function, Tf is available by default and if you want to add functions to your template, just add them to funcs which will add them to the template with their original function names. If you added anonymous functions, they will be available in your templates as func1, func2 ...etc.
func RespondAndLogError ¶
func ReturnJSON ¶
func ReturnJSON(w http.ResponseWriter, r *http.Request, v interface{})
ReturnJSON returns json to the client
func SQLInjection ¶
SQLInjection is the function to check for SQL injection attacks. Parameters:
-key: column_name, table name -value: WHERE key(OP)value, SET key=value, VALUES (key,key...)
return true for sql injection attempt and false for safe requests
func SetCookieTimeout ¶
func SetCookieTimeout()
SetCookieTimeout checks if CookieTimeout should be set to a custom value, or to use the default value
func SetSessionCookie ¶
SetSessionCookie sets the session cookie value, The the value passed in session is nil, then the session assigned will be a no user session
func StaticHandler ¶
func StaticHandler(w http.ResponseWriter, r *http.Request)
StaticHandler is a function that serves static files
func Syslogf ¶
Syslogf records a log in the system in syslog. For Windows it created a file and records the logs there.
func Tf ¶
Tf is a function for translating strings into any given language Parameters: ===========
path (string): This is where to get the translation from. It is in the format of "GROUPNAME/FILENAME" for example: "uadmin/system" lang (string): Is the language code. If empty string is passed we will use the default language. term (string): The term to translate. args (...interface{}): Is a list of args to fill the term with place holders
func TimeMetric ¶
TimeMetric runs a function and times it as a metric
func TranslateSchema ¶
func TranslateSchema(s *ModelSchema, lang string)
TranslateSchema translate a model schema
func Update ¶
func Update(a interface{}, fieldName string, value interface{}, query string, args ...interface{}) (err error)
Update !
func UploadImageHandler ¶
func UploadImageHandler(w http.ResponseWriter, r *http.Request, session *Session)
UploadImageHandler handles files sent from Tiny MCE's photo uploader
Types ¶
type ABTest ¶
type ABTest struct { Model Name string `uadmin:"required"` Type ABTestType `uadmin:"required"` StaticPath string ModelName ModelList Field FieldList PrimaryKey int Active bool Group string ResetABTest string `uadmin:"link"` }
ABTest is a model that stores an A/B test
func (ABTest) HideInDashboard ¶
HideInDashboard indicates that startup register call should hide this model in dashboard menu
type ABTestType ¶
type ABTestType int
ABTestType is the type of the AB testing: model or static
func (ABTestType) Model ¶
func (ABTestType) Model() ABTestType
Model is used to do AB testing for model values coming from database
func (ABTestType) Static ¶
func (ABTestType) Static() ABTestType
Static is used to do AB testing for static assets (images, js, css, ...)
type ABTestValue ¶
type ABTestValue struct { Model ABTest ABTest ABTestID uint Value string `uadmin:"list_exclude"` Active bool Impressions int Clicks int }
ABTestValue is a model to represent a possible value of an AB test
func (*ABTestValue) ClickThroughRate ¶
func (a *ABTestValue) ClickThroughRate() float64
ClickThroughRate returns the rate of click through of this value
func (ABTestValue) ClickThroughRate__Form__List ¶
func (a ABTestValue) ClickThroughRate__Form__List() string
ClickThroughRate__Form__List shows the click through rate in form and list views
func (ABTestValue) HideInDashboard ¶
func (ABTestValue) HideInDashboard() bool
HideInDashboard to hide it from dashboard
func (ABTestValue) Preview__Form__List ¶
func (a ABTestValue) Preview__Form__List() string
Preview__Form__List shows a preview of the AB test's value
func (*ABTestValue) String ¶
func (a *ABTestValue) String() string
type APIDisabledAdder ¶
APIDisabledAdder is an interface for models to disable access to add function in dAPI
type APIDisabledDeleter ¶
APIDisabledDeleter is an interface for models to disable access to delete function in dAPI
type APIDisabledEditor ¶
APIDisabledEditor is an interface for models to disable access to edit function in dAPI
type APIDisabledReader ¶
APIDisabledReader is an interface for models to disable access to read function in dAPI
type APIDisabledSchemer ¶
APIDisabledSchemer is an interface for models to disable access to schema function in dAPI
type APILogAdder ¶
APILogAdder is an interface for models to control logging their add function in dAPI
type APILogDeleter ¶
APILogDeleter is an interface for models to control logging their delete function in dAPI
type APILogEditor ¶
APILogEditor is an interface for models to control logging their edit function in dAPI
type APILogReader ¶
APILogReader is an interface for models to control logging their read function in dAPI
type APILogSchemer ¶
APILogSchemer is an interface for models to control logging their schema function in dAPI
type APIPostQueryAdder ¶
type APIPostQueryAdder interface {
APIPostQueryAdd(http.ResponseWriter, *http.Request, map[string]interface{}) bool
}
APIPostQueryAdder is an interface for models to run after processing add function in dAPI and before returning the results. Returning false stops the rest of the process from happening
type APIPostQueryDeleter ¶
type APIPostQueryDeleter interface {
APIPostQueryDelete(http.ResponseWriter, *http.Request, map[string]interface{}) bool
}
APIPostQueryDeleter is an interface for models to run after processing delete function in dAPI and before returning the results. Returning false stops the rest of the process from happening
type APIPostQueryEditor ¶
type APIPostQueryEditor interface {
APIPostQueryEdit(http.ResponseWriter, *http.Request, map[string]interface{}) bool
}
APIPostQueryEditor is an interface for models to run after processing edit function in dAPI and before returning the results. Returning false stops the rest of the process from happening
type APIPostQueryReader ¶
type APIPostQueryReader interface {
APIPostQueryRead(http.ResponseWriter, *http.Request, map[string]interface{}) bool
}
APIPostQueryReader is an interface for models to run after processing read function in dAPI and before returning the results. Returning false stops the rest of the process from happening
type APIPostQuerySchemer ¶
type APIPostQuerySchemer interface {
APIPostQuerySchema(http.ResponseWriter, *http.Request, map[string]interface{}) bool
}
APIPostQuerySchemer is an interface for models to run after processing schema function in dAPI and before returning the results. Returning false stops the rest of the process from happening
type APIPreQueryAdder ¶
type APIPreQueryAdder interface {
APIPreQueryAdd(http.ResponseWriter, *http.Request) bool
}
APIPreQueryAdder is an interface for models to run before processing add function in dAPI. Returning false stops the rest of the process from happening
type APIPreQueryDeleter ¶
type APIPreQueryDeleter interface {
APIPreQueryDelete(http.ResponseWriter, *http.Request) bool
}
APIPreQueryDeleter is an interface for models to run before processing delete function in dAPI. Returning false stops the rest of the process from happening
type APIPreQueryEditor ¶
type APIPreQueryEditor interface {
APIPreQueryEdit(http.ResponseWriter, *http.Request) bool
}
APIPreQueryEditor is an interface for models to run before processing edit function in dAPI. Returning false stops the rest of the process from happening
type APIPreQueryReader ¶
type APIPreQueryReader interface {
APIPreQueryRead(http.ResponseWriter, *http.Request) bool
}
APIPreQueryReader is an interface for models to run before processing read function in dAPI. Returning false stops the rest of the process from happening
type APIPreQuerySchemer ¶
type APIPreQuerySchemer interface {
APIPreQuerySchema(http.ResponseWriter, *http.Request) bool
}
APIPreQuerySchemer is an interface for models to run before processing schema function in dAPI. Returning false stops the rest of the process from happening
type APIPublicAdder ¶
APIPublicAdder is an interface for models to control public access to add function in dAPI
type APIPublicDeleter ¶
APIPublicDeleter is an interface for models to control public access to delete function in dAPI
type APIPublicEditor ¶
APIPublicEditor is an interface for models to control public access to read function in dAPI
type APIPublicReader ¶
APIPublicReader is an interface for models to control public access to read function in dAPI
type APIPublicSchemer ¶
APIPublicSchemer is an interface for models to control public access to schema function in dAPI
type Action ¶
type Action int
Action !
func (Action) PasswordResetDenied ¶
PasswordResetDenied !
func (Action) PasswordResetRequest ¶
PasswordResetRequest !
func (Action) PasswordResetSuccessful ¶
PasswordResetSuccessful !
type Approval ¶
type Approval struct { Model ModelName string `uadmin:"read_only"` ModelPK uint `uadmin:"read_only"` ColumnName string `uadmin:"read_only"` OldValue string `uadmin:"read_only"` NewValue string NewValueDescription string `uadmin:"read_only"` ChangedBy string `uadmin:"read_only"` ChangeDate time.Time `uadmin:"read_only"` ApprovalAction ApprovalAction ApprovalBy string `uadmin:"read_only"` ApprovalDate *time.Time `uadmin:"read_only"` ViewRecord string `uadmin:"link"` UpdatedBy string `uadmin:"read_only;hidden;list_exclude"` }
Approval is a model that stores approval data
func (Approval) HideInDashboard ¶
HideInDashboard indicates that startup register call should hide this model in dashboard menu
type ApprovalAction ¶
type ApprovalAction int
ApprovalAction is a selection of approval actions
func (ApprovalAction) Approved ¶
func (ApprovalAction) Approved() ApprovalAction
Approved is an accepted change
func (ApprovalAction) Rejected ¶
func (ApprovalAction) Rejected() ApprovalAction
Rejected is a rejected change
type AutoMigrater ¶
type AutoMigrater interface {
AutoMigrate() bool
}
type DBSettings ¶
type DBSettings struct { Type string `json:"type"` // sqlite, mysql, postgres Name string `json:"name"` // File/DB name User string `json:"user"` Password string `json:"password"` Host string `json:"host"` Port int `json:"port"` Timezone string `json:"timezone"` SSLMode string `json:"sslmode"` }
DBSettings !
var Database *DBSettings
Database is the active Database settings
type DashboardMenu ¶
type DashboardMenu struct { Model MenuName string `uadmin:"required;list_exclude;multilingual;filter"` URL string `uadmin:"required"` ToolTip string Icon string `uadmin:"image"` Cat string `uadmin:"filter"` Hidden bool `uadmin:"filter"` }
DashboardMenu !
func (DashboardMenu) GetImageSize ¶
func (m DashboardMenu) GetImageSize() (int, int)
GetImageSize customizes the icons as 128x128
func (DashboardMenu) String ¶
func (m DashboardMenu) String() string
type F ¶
type F struct { Name string DisplayName string ColumnName string Type string TypeName string Value interface{} Help string Max interface{} Min interface{} Format string DefaultValue string Required bool Pattern string PatternMsg string Hidden bool ReadOnly string Searchable bool Filter bool ListDisplay bool FormDisplay bool CategoricalFilter bool Translations []translation Choices []Choice IsMethod bool ErrMsg string ProgressBar map[float64]string `json:"-"` LimitChoicesTo func(interface{}, *User) []Choice `json:"-"` UploadTo string Encrypt bool Approval bool NewValue interface{} OldValue interface{} ChangedBy string ChangeDate *time.Time ApprovalAction ApprovalAction ApprovalDate *time.Time ApprovalBy string ApprovalID uint WebCam bool Stringer bool Deprecated bool }
F is a field
func (F) MarshalJSON ¶
MarshalJSON customizes F json export
type FieldList ¶
type FieldList int
FieldList is a list of fields from schema for a registered model
type FieldType ¶
type FieldType int
FieldType for field type in builder field
func (FieldType) DateTimePtr ¶
DateTimePtr for time.Time pointer type
func (FieldType) Multilingual ¶
Multilingual for multiminual type
func (FieldType) ProgressBar ¶
ProgressBar for progressbar type
type GetImageSizer ¶
GetImageSizer can be inplemented for any model to customize the image size uploaded to that model
type GroupPermission ¶
type GroupPermission struct { Model DashboardMenu DashboardMenu `uadmin:"required;filter"` DashboardMenuID uint UserGroup UserGroup `uadmin:"required;filter"` UserGroupID uint Read bool `uadmin:"filter"` Add bool `uadmin:"filter"` Edit bool `uadmin:"filter"` Delete bool `uadmin:"filter"` Approval bool `uadmin:"filter"` }
GroupPermission !
func (*GroupPermission) Save ¶
func (g *GroupPermission) Save()
func (GroupPermission) String ¶
func (g GroupPermission) String() string
type HideInDashboarder ¶
type HideInDashboarder interface {
HideInDashboard() bool
}
HideInDashboarder used to check if a model should be hidden in dashboard
type Language ¶
type Language struct { Model EnglishName string `uadmin:"required;read_only;filter;search"` Name string `uadmin:"required;read_only;filter;search"` Flag string `uadmin:"image;list_exclude"` Code string `uadmin:"filter;read_only;list_exclude"` RTL bool `uadmin:"list_exclude"` Default bool `uadmin:"help:Set as the default language;list_exclude"` Active bool `uadmin:"help:To show this in available languages;filter"` AvailableInGui bool `uadmin:"help:The App is available in this language;read_only"` }
Language !
var DefaultLang Language
DefaultLang is the default language of the system.
func GetActiveLanguages ¶
func GetActiveLanguages() []Language
GetActiveLanguages returns a list of active langages
func GetDefaultLanguage ¶
func GetDefaultLanguage() Language
GetDefaultLanguage returns the default language
type Log ¶
type Log struct { Model Username string `uadmin:"filter;read_only"` Action Action `uadmin:"filter;read_only"` TableName string `uadmin:"filter;read_only"` TableID int `uadmin:"filter;read_only"` Activity string `uadmin:"code;read_only" sql:"type:longtext"` RollBack string `uadmin:"link;"` CreatedAt time.Time `uadmin:"filter;read_only"` }
Log !
func (Log) HideInDashboard ¶
HideInDashboard indicates that startup register call should hide this model in dashboard menu
func (*Log) ParseRecord ¶
func (l *Log) ParseRecord(a reflect.Value, modelName string, ID uint, user *User, action Action, r *http.Request) (err error)
ParseRecord !
func (*Log) PasswordReset ¶
PasswordReset !
type Model ¶
Model is the standard struct to be embedded in any other struct to make it a model for uadmin
type ModelSchema ¶
type ModelSchema struct { Name string // Name of the Model e.g. OrderItem DisplayName string // Display Name of the model e.g. Order Items ModelName string // URL e.g. orderitem TableName string // DB table name e.g. order_items Category string ModelID uint Inlines []*ModelSchema InlinesData []listData Fields []F IncludeFormJS []string IncludeListJS []string FormModifier func(*ModelSchema, interface{}, *User) `json:"-"` ListModifier func(*ModelSchema, *User) (string, []interface{}) `json:"-"` FormTheme string ListTheme string }
ModelSchema for a form
func (ModelSchema) FieldByColumnName ¶
func (s ModelSchema) FieldByColumnName(a string) *F
FieldByName returns a field from a ModelSchema by name or nil if it doesn't exist
func (ModelSchema) FieldByName ¶
func (s ModelSchema) FieldByName(a string) *F
FieldByName returns a field from a ModelSchema by name or nil if it doesn't exist
func (*ModelSchema) GetFormTheme ¶
func (s *ModelSchema) GetFormTheme() string
GetFormTheme returns the theme for this model or the global theme if there is no assigned theme for the model
func (*ModelSchema) GetListTheme ¶
func (s *ModelSchema) GetListTheme() string
GetListTheme returns the theme for this model or the global theme if there is no assigned theme for the model
func (ModelSchema) MarshalJSON ¶
func (s ModelSchema) MarshalJSON() ([]byte, error)
MarshalJSON customizes json export for models schema
type SchemaCategory ¶
type SchemaCategory interface {
SchemaCategory() string
}
SchemaCategory provides a default category for the model. This can be customized later from the UI
type Session ¶
type Session struct { Model Key string User User `uadmin:"filter"` UserID uint LoginTime time.Time LastLogin time.Time Active bool `uadmin:"filter"` IP string `uadmin:"filter"` PendingOTP bool `uadmin:"filter"` ExpiresOn *time.Time }
Session !
func IsAuthenticated ¶
IsAuthenticated returns if the http.Request is authenticated or not
func Login2FAKey ¶
Login2FA login using username, password and otp for users with OTPRequired = true
func (Session) HideInDashboard ¶
HideInDashboard to return false and auto hide this from dashboard
type Setting ¶
type Setting struct { Model Name string `uadmin:"required;filter;search"` DefaultValue string DataType DataType `uadmin:"required;filter"` Value string Help string `uadmin:"search" sql:"type:text;"` Category SettingCategory `uadmin:"required;filter"` CategoryID uint Code string `uadmin:"read_only;search"` }
Setting model stored system settings
func (*Setting) ApplyValue ¶
func (s *Setting) ApplyValue()
ApplyValue changes uAdmin global variables' value based in the setting value
func (*Setting) GetValue ¶
func (s *Setting) GetValue() interface{}
GetValue returns an interface representing the value of the setting
func (*Setting) ParseFormValue ¶
ParseFormValue takes the value of a setting from an HTTP request and saves in the instance of setting
type SettingCategory ¶
SettingCategory is a category for system settings
type User ¶
type User struct { Model Username string `uadmin:"required;filter;search"` FirstName string `uadmin:"filter;search"` LastName string `uadmin:"filter;search"` Password string `uadmin:"required;password;help:To reset password, clear the field and type a new password.;list_exclude"` Email string `uadmin:"email;search"` Active bool `uadmin:"filter"` Admin bool `uadmin:"filter"` RemoteAccess bool `uadmin:"filter"` UserGroup UserGroup `uadmin:"filter"` UserGroupID uint Photo string `uadmin:"image"` //Language []Language `gorm:"many2many:user_languages" listExclude:"true"` LastLogin *time.Time `uadmin:"read_only"` ExpiresOn *time.Time OTPRequired bool OTPSeed string `uadmin:"list_exclude;hidden;read_only;password"` PasswordReset *time.Time }
User !
func GetUserFromRequest ¶
GetUserFromRequest returns a user from a request
func (*User) GeneratePasswordResetLink ¶
func (*User) GeneratePasswordResetOTP ¶
func (*User) GetAccess ¶
func (u *User) GetAccess(modelName string) UserPermission
GetAccess returns the user's permission to a dashboard menu based on their admin status, group and user permissions
func (*User) GetDashboardMenu ¶
func (u *User) GetDashboardMenu() (menus []DashboardMenu)
GetDashboardMenu !
func (*User) HasAccess ¶
func (u *User) HasAccess(modelName string) UserPermission
HasAccess returns the user level permission to a model. The modelName the the URL of the model
func (*User) Login ¶
Login Logs in user using password and otp. If there is no OTP, just pass an empty string
func (*User) VerifyOTPAtPasswordReset ¶
type UserGroup ¶
UserGroup !
func (*UserGroup) HasAccess ¶
func (u *UserGroup) HasAccess(modelName string) GroupPermission
HasAccess !
type UserPermission ¶
type UserPermission struct { Model DashboardMenu DashboardMenu `uadmin:"filter"` DashboardMenuID uint `` User User `uadmin:"filter"` UserID uint `` Read bool `uadmin:"filter"` Add bool `uadmin:"filter"` Edit bool `uadmin:"filter"` Delete bool `uadmin:"filter"` Approval bool `uadmin:"filter"` }
UserPermission !
func (UserPermission) HideInDashboard ¶
func (UserPermission) HideInDashboard() bool
HideInDashboard to return false and auto hide this from dashboard
func (*UserPermission) Save ¶
func (u *UserPermission) Save()
func (UserPermission) String ¶
func (u UserPermission) String() string
Source Files ¶
- 404_handler.go
- abtest.go
- abtest_value.go
- admin.go
- api_errors.go
- api_handler.go
- approval.go
- auth.go
- check_csrf.go
- cors_handler.go
- crop_image_handler.go
- d_api.go
- d_api_add.go
- d_api_allmodels.go
- d_api_auth.go
- d_api_change_password.go
- d_api_delete.go
- d_api_edit.go
- d_api_helper.go
- d_api_login.go
- d_api_logout.go
- d_api_method.go
- d_api_read.go
- d_api_reset_password.go
- d_api_schema.go
- d_api_signup.go
- d_api_upload.go
- dashboard_menu.go
- data.go
- datetime.go
- db.go
- db_helper.go
- delete_handler.go
- encrypt.go
- export.go
- field_type.go
- forgot_password_handler.go
- form_handler.go
- generate_translation.go
- get_display_name.go
- get_fields_api.go
- get_form_data.go
- get_list_data.go
- get_models_api.go
- get_schema.go
- global.go
- grouppermission.go
- handler.go
- home_handler.go
- language.go
- list_handler.go
- load_initial_data.go
- log.go
- login_handler.go
- logout_handler.go
- main_handler.go
- media_handler.go
- metrics.go
- model.go
- new_model.go
- openapi.go
- otp.go
- params_to_instance.go
- password_reset_handler.go
- process_form.go
- process_upload.go
- profile_handler.go
- rate_limit.go
- register.go
- render_html.go
- render_html_multi.go
- representation.go
- revert_log_handler.go
- schema.go
- search_api_handler.go
- send_email.go
- server.go
- services.go
- session.go
- setting.go
- setting_handler.go
- settingcategory.go
- sql_injection.go
- static_handler.go
- syslog.go
- trail.go
- trail_api_handler.go
- trail_handler.go
- translation.go
- upload_image_handler.go
- user.go
- usergroup.go
- userpermission.go