func (T POGSvc) Add(t POGc) { u, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil") if error == "" { s := SecInfo{u.Domain, u.SecurityToken} Add(t.GUUserID, t.RecordID, t.Name, t.AccessLevel, t.OtherData, s) } else { T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("Security Token Not Incorrect")) } }
func (T TenantSvc) CreateTenant(t Tenant) { //fmt.Println(T.Context.Request().Header["SecurityToken"]) user, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil") if error == "" { th := TenantHandler{} b, _ := json.Marshal(th.CreateTenant(t, user, false)) T.ResponseBuilder().SetResponseCode(200).WriteAndOveride(b) } }
func (T TenantSvc) AcceptRequest(securityLevel, RequestToken string, accept bool) bool { //fmt.Println(T.Context.Request().Header.Get("Securitytoken")) user, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil") if error == "" { th := TenantHandler{} return th.AcceptRequest(user, securityLevel, RequestToken, accept) } else { T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken not Autherized")) return false } }
func (T TenantSvc) InviteUser(users []InviteUsers) { //fmt.Println(T.Context.Request().Header.Get("Securitytoken")) user, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil") if error == "" { th := TenantHandler{} th.AddUserToTenant(user, users) } else { T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken not Autherized")) return } }
func (T POGSvc) GetUsers(RecordID string) (c []string) { u, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil") if error == "" { s := SecInfo{u.Domain, u.SecurityToken} c = GetUsers(RecordID, s) return } else { T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("Security Token Not Incorrect")) return } }
func (T TenantSvc) GetTenant(TenantID string) Tenant { //fmt.Println(T.Context.Request().Header.Get("Securitytoken")) _, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil") //outCrt = TenantAutherize{} if error == "" { th := TenantHandler{} return th.GetTenant(TenantID) } else { T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken not Autherized")) return Tenant{} } }
func (T TenantSvc) Subciribe(TenantID string) bool { //users :=InviteUsers[]{"Sss",sss,sss} //fmt.Println(T.Context.Request().Header.Get("Securitytoken")) user, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil") if error == "" { th := TenantHandler{} return th.RequestToTenant(user, TenantID) } else { T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken not Autherized")) return } }
func (T TenantSvc) GetTenants(securityToken string) []TenantMinimum { //fmt.Println() tns := []TenantMinimum{} user, error := session.GetSession(securityToken, "Nil") //outCrt = TenantAutherize{} if error == "" { th := TenantHandler{} return th.GetTenantsForUser(user.UserID) } else { T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken not Autherized")) } return tns }
func (T TenantSvc) Autherized(TenantID string) (outCrt TenantAutherized) { //fmt.Println(T.Context.Request().Header["SecurityToken"]) user, error := session.GetSession(T.Context.Request().Header.Get("Securitytoken"), "Nil") //outCrt = TenantAutherize{} if error == "" { th := TenantHandler{} b, d := th.Autherized(TenantID, user) if b { outCrt = d return d } else { T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("Tenant ID " + TenantID + " not Atherized")) return } } else { T.ResponseBuilder().SetResponseCode(401).WriteAndOveride([]byte("SecurityToken not Autherized")) return } }
func (h *AuthHandler) GetSession(key, Domain string) (AuthCertificate, string) { //bytes, err := client.Go(key, "s.duosoftware.auth", "sessions").GetOne().ByUniqueKey(key).Ok() //term.Write("GetSession For SecurityToken "+key, term.Debug) a, err := session.GetSession(key, Domain) var c AuthCertificate if err == "" { c.ClientIP = a.ClientIP c.DataCaps = a.DataCaps c.Domain = a.Domain c.Email = a.Email c.Name = a.Name c.SecurityToken = a.SecurityToken c.UserID = a.UserID c.Username = a.Username return c, "" } else { term.Write("GetSession Error "+err, term.Error) } term.Write("GetSession No Session for SecurityToken "+key, term.Debug) return c, "Error Session Not Found" }