Преглед на файлове

models

- Claims
- libphonenumber > invalidate number region
Alexey Kim преди 2 години
родител
ревизия
a140446432
променени са 2 файла, в които са добавени 20 реда и са изтрити 0 реда
  1. 14 0
      model/claims.go
  2. 6 0
      model/phone.go

+ 14 - 0
model/claims.go

@@ -0,0 +1,14 @@
+package model
+
+import "github.com/mitchellh/mapstructure"
+
+type Claims struct {
+	Email     string `mapstructure:"email"`
+	Sub       string `mapstructure:"sub"`
+	Scope     string `mapstructure:"scope"`
+	SessionId string `mapstructure:"sid"`
+}
+
+func (c *Claims) Unmarshall(source map[string]any) error {
+	return mapstructure.Decode(source, c)
+}

+ 6 - 0
model/phone.go

@@ -47,6 +47,12 @@ func NewPhoneNumber(number, region string, verified bool) (*Phone, error) {
 		return nil, err
 	}
 
+	if p.number.CountryCode != nil {
+		if cc := phonenumbers.GetRegionCodeForCountryCode(int(*p.number.CountryCode)); cc != p.PhoneRegion {
+			p.PhoneRegion = cc
+		}
+	}
+
 	return &p, nil
 }