Example #1
0
func (p *loginAccountContext) SetFromJSON(obj jsonhelper.JSONObject) {
	p.username = obj.GetAsString("username")
	p.password = obj.GetAsString("password")
	p.inputValidated = false
	p.user = nil
	p.result = nil
}
Example #2
0
func (p *updateContactContext) SetFromJSON(obj jsonhelper.JSONObject) {
	contact := new(dm.Contact)
	if obj == nil {
		contact = nil
	} else {
		json.Unmarshal([]byte(obj.String()), contact)
	}
	p.contact = contact
}
Example #3
0
func (p *Name) FromJSON(o jsonhelper.JSONObject) {
	p.GivenName = o.GetAsString("givenName")
	p.MiddleName = o.GetAsString("middleName")
	p.FamilyName = o.GetAsString("familyName")
	p.Prefix = o.GetAsString("prefix")
	p.Suffix = o.GetAsString("suffix")
	p.GivenNameSound = o.GetAsString("givenNameSound")
	p.FamilyNameSound = o.GetAsString("familyNameSound")
}
Example #4
0
func (p *SetPasswordRequestHandler) HandleInputHandlerAfterSetup(cxt SetPasswordContext) (int, http.Header, io.WriterTo) {
	errors := make(map[string][]error)
	var obj jsonhelper.JSONObject
	var err error
	authDS := p.authDS
	if user := cxt.User(); user != nil {
		var userPassword *dm.UserPassword
		if user != nil {
			userPassword = dm.NewUserPassword(user.Id, cxt.Password())
		} else {
			userPassword = dm.NewUserPassword("", cxt.Password())
		}
		userPassword.Validate(true, errors)
		if len(errors) == 0 {
			userPassword, err = authDS.StoreUserPassword(userPassword)
		}
		obj = jsonhelper.NewJSONObject()
		userObj, _ := jsonhelper.Marshal(user)
		obj.Set("user", userObj)
		obj.Set("type", "user")
		obj.Set("message", "password changed")
	} else {
		return apiutil.OutputErrorMessage(ERR_MUST_SPECIFY_USERNAME.Error(), time.Time{}, http.StatusBadRequest, nil)
	}
	if len(errors) > 0 {
		return apiutil.OutputErrorMessage("Value errors. See result", errors, http.StatusBadRequest, nil)
	}
	if err != nil {
		return apiutil.OutputErrorMessage(err.Error(), time.Time{}, http.StatusInternalServerError, nil)
	}
	cxt.SetResult(obj)
	return 0, nil, nil
}
Example #5
0
func (p *createAccountContext) SetFromJSON(obj jsonhelper.JSONObject) {
	p.user = nil
	p.consumer = nil
	p.externalUser = nil
	theType := p.theType
	if theType == "" {
		theType = obj.GetAsString("type")
	}
	switch theType {
	case "user":
		p.user = new(dm.User)
		p.user.InitFromJSONObject(obj)
	case "consumer":
		p.consumer = new(dm.Consumer)
		p.consumer.InitFromJSONObject(obj)
	case "external_user":
		p.externalUser = new(dm.ExternalUser)
		p.externalUser.InitFromJSONObject(obj)
	}
}
Example #6
0
func (p *googleUserInfoResult) FromJSON(props jsonhelper.JSONObject) {
	p.id = props.GetAsObject("id").GetAsString("$t")
	authorArr := props.GetAsArray("author")
	if len(authorArr) > 0 {
		author := jsonhelper.JSONValueToObject(authorArr[0])
		p.name = author.GetAsObject("name").GetAsString("$t")
		p.email = author.GetAsObject("email").GetAsString("$t")
	}
	for _, l := range props.GetAsArray("link") {
		m := jsonhelper.JSONValueToObject(l)
		if m.GetAsString("rel") == _GOOGLE_USERINFO_FEED_REL {
			p.uri = m.GetAsString("href")
		}
	}
	p.updated = props.GetAsObject("updated").GetAsTime("$t", GOOGLE_DATETIME_FORMAT)
}
Example #7
0
func (p *Address) FromJSON(o jsonhelper.JSONObject) {
	p.Street = o.GetAsString("street")
	p.City = o.GetAsString("city")
	p.StateOrProvince = o.GetAsString("stateOrProvince")
	p.PostalCode = o.GetAsString("postalCode")
	p.Country = o.GetAsString("country")
	p.CountryCode = o.GetAsString("countryCode")
}
Example #8
0
func (p *ExternalUser) InitFromJSONObject(obj jsonhelper.JSONObject) {
	p.PersistableModel.InitFromJSONObject(obj)
	p.ConsumerId = obj.GetAsString("consumer_id")
	p.ExternalUserId = obj.GetAsString("external_user_id")
	p.Name = obj.GetAsString("name")
}
Example #9
0
func (p *Consumer) InitFromJSONObject(obj jsonhelper.JSONObject) {
	p.PersistableModel.InitFromJSONObject(obj)
	p.DomainName = obj.GetAsString("domain_name")
	p.HomePage = obj.GetAsString("home_page")
	p.AuthorizationPage = obj.GetAsString("authorization_page")
	p.ShortName = obj.GetAsString("short_name")
	p.Name = obj.GetAsString("name")
	p.Email = obj.GetAsString("email")
	p.PhoneNumber = obj.GetAsString("phone_number")
	p.IsTrusted = obj.GetAsBool("is_trusted")
	p.IsSuggested = obj.GetAsBool("is_suggested")
	p.AllowLogin = obj.GetAsBool("allow_login")
	p.DisableLoginAt = obj.GetAsInt64("disable_login_at")
}
Example #10
0
func (p *facebookLocation) FromJSON(props jsonhelper.JSONObject) {
	p.id = props.GetAsString("id")
	p.name = props.GetAsString("name")
}
Example #11
0
func (p *User) InitFromJSONObject(obj jsonhelper.JSONObject) {
	p.PersistableModel.InitFromJSONObject(obj)
	p.Role = obj.GetAsInt32("role")
	p.Name = obj.GetAsString("name")
	p.Username = obj.GetAsString("username")
	p.Email = obj.GetAsString("email")
	p.PhoneNumber = obj.GetAsString("phone_number")
	p.Address = obj.GetAsString("address")
	p.ContactId = obj.GetAsString("contact_id")
	p.AllowLogin = obj.GetAsBool("allow_login")
	p.IsPayingUser = obj.GetAsBool("is_paying_user")
	p.Notes = obj.GetAsString("notes")
	p.DisableLoginAt = obj.GetAsInt64("disable_login_at")
}
Example #12
0
func (p *linkedInClient) Initialize(properties jsonhelper.JSONObject) {
	if p.currentCredentials == nil {
		p.currentCredentials = NewStandardAuthToken()
	}
	if properties == nil {
		return
	}
	if v := properties.GetAsString("linkedin.api.key"); len(v) > 0 {
		p.consumerKey = v
		//p.Credentials.Token = v
	}
	if v := properties.GetAsString("linkedin.client.redirect_uri"); len(v) > 0 {
		p.callbackUrl = v
	}
	if v := properties.GetAsString("linkedin.secret.key"); len(v) > 0 {
		p.consumerSecret = v
		//p.Credentials.Secret = v
	}
	if v := properties.GetAsString("linkedin.oauth1.scope"); len(v) > 0 {
		//p.Scope = v
	}
	if v := properties.GetAsString("linkedin.client.token"); len(v) > 0 {
		p.currentCredentials.SetToken(v)
	}
	if v := properties.GetAsString("linkedin.client.secret"); len(v) > 0 {
		p.currentCredentials.SetSecret(v)
	}
}
Example #13
0
func (p *setPasswordContext) SetFromJSON(obj jsonhelper.JSONObject) {
	p.password = obj.GetAsString("password")
	p.result = nil
}
Example #14
0
func (p *yahooUserInfoIm) FromJSON(props jsonhelper.JSONObject) {
	p.handle = props.GetAsString("handle")
	p.id = props.GetAsInt("id")
	p.theType = props.GetAsString("type")
}
Example #15
0
func (p *Date) FromJSON(o jsonhelper.JSONObject) {
	p.Year = o.GetAsInt("year")
	p.Month = o.GetAsInt("month")
	p.Day = o.GetAsInt("day")
}
Example #16
0
func (p *yahooClient) Initialize(properties jsonhelper.JSONObject) {
	if p.currentCredentials == nil {
		p.currentCredentials = &yahooAccessTokenResult{}
	}
	if properties == nil {
		return
	}
	if v := properties.GetAsString("yahoo.realm"); len(v) > 0 {
		p.realm = v
	}
	if v := properties.GetAsString("yahoo.consumer.key"); len(v) > 0 {
		p.consumerKey = v
		//p.Credentials.Token = v
	}
	if v := properties.GetAsString("yahoo.consumer.secret"); len(v) > 0 {
		p.consumerSecret = v
		//p.Credentials.Secret = v
	}
	if v := properties.GetAsString("yahoo.client.redirect_uri"); len(v) > 0 {
		p.callbackUrl = v
	}
	if v := properties.GetAsString("yahoo.oauth1.scope"); len(v) > 0 {
		//p.Scope = v
	}
	if v := properties.GetAsString("yahoo.client.token"); len(v) > 0 {
		p.currentCredentials.SetToken(v)
	}
	if v := properties.GetAsString("yahoo.client.secret"); len(v) > 0 {
		p.currentCredentials.SetSecret(v)
	}
}
Example #17
0
func (p *yahooUserInfoResult) FromJSON(props jsonhelper.JSONObject) {
	p.guid = props.GetAsString("guid")
	p.uri = props.GetAsString("uri")
	p.birthYear = props.GetAsInt("birthYear")
	p.birthdate = props.GetAsString("birthdate")
	p.created = props.GetAsTime("created", YAHOO_DATETIME_FORMAT)
	p.displayAge = props.GetAsInt("displayAge")
	emails := props.GetAsArray("emails")
	p.emails = make([]YahooUserInfoEmail, len(emails))
	for i, email := range emails {
		v := new(yahooUserInfoEmail)
		v.FromJSON(jsonhelper.JSONValueToObject(email))
		p.emails[i] = v
	}
	p.familyName = props.GetAsString("familyName")
	p.givenName = props.GetAsString("givenName")
	p.gender = props.GetAsString("gender")
	ims := props.GetAsArray("ims")
	p.ims = make([]YahooUserInfoIm, len(ims))
	for i, im := range ims {
		v := new(yahooUserInfoIm)
		v.FromJSON(jsonhelper.JSONValueToObject(im))
		p.ims[i] = v
	}
	p.lang = props.GetAsString("lang")
	p.location = props.GetAsString("location")
	p.memberSince = props.GetAsTime("memberSince", YAHOO_DATETIME_FORMAT)
	p.nickname = props.GetAsString("nickname")
	p.profileUrl = props.GetAsString("profileUrl")
	p.searchable = props.GetAsBool("searchable")
	p.timeZone = props.GetAsString("timeZone")
	p.updated = props.GetAsTime("updated", YAHOO_DATETIME_FORMAT)
	p.isConnected = props.GetAsBool("isConnected")
}
Example #18
0
func (p *yahooUserInfoEmail) FromJSON(props jsonhelper.JSONObject) {
	p.yahooUserInfoIm.FromJSON(props)
	p.isPrimary = props.GetAsBool("primary")
}
Example #19
0
func (p *smugMugUserInfoResult) FromJSON(props jsonhelper.JSONObject) {
	LogDebug("user info result from json: ", props)
	p.id = props.GetAsInt64("id")
	p.accountStatus = props.GetAsString("AccountStatus")
	p.accountType = props.GetAsString("AccountType")
	p.fileSizeLimit = props.GetAsInt64("FileSizeLimit")
	p.name = props.GetAsString("Name")
	p.nickname = props.GetAsString("NickName")
	p.smugVault = props.GetAsBool("SmugVault")
	p.url = props.GetAsString("URL")
}
Example #20
0
func (p *smugMugClient) Initialize(properties jsonhelper.JSONObject) {
	if p.currentCredentials == nil {
		p.currentCredentials = NewStandardAuthToken()
	}
	if properties == nil {
		return
	}
	if v := properties.GetAsString("smugmug.realm"); len(v) > 0 {
		p.realm = v
	}
	if v := properties.GetAsString("smugmug.app.name"); len(v) > 0 {
		p.appName = v
	}
	if v := properties.GetAsString("smugmug.consumer.key"); len(v) > 0 {
		p.consumerKey = v
		//p.Credentials.Token = v
	}
	if v := properties.GetAsString("smugmug.consumer.secret"); len(v) > 0 {
		p.consumerSecret = v
		//p.Credentials.Secret = v
	}
	if v := properties.GetAsString("smugmug.client.redirect_uri"); len(v) > 0 {
		p.callbackUrl = v
	}
	if v := properties.GetAsString("smugmug.oauth1.scope"); len(v) > 0 {
		//p.Scope = v
	}
	if v := properties.GetAsString("smugmug.client.token"); len(v) > 0 {
		p.currentCredentials.SetToken(v)
	}
	if v := properties.GetAsString("smugmug.client.secret"); len(v) > 0 {
		p.currentCredentials.SetSecret(v)
	}
}
Example #21
0
func (p *PersistableModel) InitFromJSONObject(obj jsonhelper.JSONObject) {
	p.Id = obj.GetAsString("id")
	p.Etag = obj.GetAsString("etag")
	p.CreatedAt = obj.GetAsInt64("created_at")
	p.ModifiedAt = obj.GetAsInt64("modified_at")
}
Example #22
0
func (p *linkedInUserInfoResult) FromJSON(props jsonhelper.JSONObject) {
	p.id = props.GetAsString("id")
	p.firstName = props.GetAsString("firstName")
	p.lastName = props.GetAsString("lastName")
	p.publicProfileUrl = props.GetAsString("publicProfileUrl")
}