package handler import ( "context" "time" "git.coopgo.io/coopgo-apps/silvermobi/models" ) func (h *SilverMobiHandler) Login(ctx context.Context, username string, password string) (jwt string, err error) { var ( account *models.Account pTTL time.Duration ) if account, err = h.Services.MobilityAccounts.Login(ctx, username, password, "silvermobi"); err != nil { return } key := h.Config.GetString("identification.local.jwt_secret") ttl := h.Config.GetString("identification.local.ttl") if pTTL, err = time.ParseDuration(ttl); err != nil { return "", err } return account.CreateToken(pTTL, key) } func (h *SilverMobiHandler) Register(ctx context.Context, username string, password string, email string, phone_number string, first_name string, last_name string) (jwt string, err error) { var ( account *models.Account pTTL time.Duration ) if account, err = h.Services.MobilityAccounts.Register( ctx, username, password, email, phone_number, map[string]any{ "first_name": first_name, "last_name": last_name, "email": email, "phone_number": phone_number, }, "silvermobi", ); err != nil { return "", err } key := h.Config.GetString("identification.local.jwt_secret") ttl := h.Config.GetString("identification.local.ttl") if pTTL, err = time.ParseDuration(ttl); err != nil { return "", err } return account.CreateToken(pTTL, key) }