Skip to content

Commit c6ceb0d

Browse files
author
li
committed
Fix me profile
1 parent 73bf530 commit c6ceb0d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

safe_user.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
// If you want to register safe user, you need to call UpdateTipPin upgrade TIP PIN first.
15-
func RegisterSafe(ctx context.Context, userId, spendPrivateKeySeed string, su *SafeUser) (*User, error) {
15+
func RegisterSafe(ctx context.Context, userId, spendPrivateKeySeed string, su *SafeUser) (*UserMeView, error) {
1616
s, err := hex.DecodeString(spendPrivateKeySeed)
1717
if err != nil {
1818
return nil, err
@@ -51,8 +51,8 @@ func RegisterSafe(ctx context.Context, userId, spendPrivateKeySeed string, su *S
5151
return nil, err
5252
}
5353
var resp struct {
54-
Data *User `json:"data"`
55-
Error *Error `json:"error,omitempty"`
54+
Data *UserMeView `json:"data"`
55+
Error *Error `json:"error,omitempty"`
5656
}
5757
err = json.Unmarshal(body, &resp)
5858
if err != nil {

user.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ type User struct {
3131
ServerPublicKey string `json:"server_public_key"`
3232
}
3333

34+
type UserMeView struct {
35+
User
36+
SessionId string `json:"session_id"`
37+
HasPIN bool `json:"has_pin"`
38+
}
39+
3440
type Membership struct {
3541
Plan string `json:"plan"`
3642
ExpiredAt time.Time `json:"expired_at"`
@@ -223,14 +229,14 @@ func UpdatePin(ctx context.Context, oldEncryptedPin, encryptedPin string, su *Sa
223229
return nil
224230
}
225231

226-
func UserMeWithRequestID(ctx context.Context, accessToken, requestID string) (*User, error) {
232+
func UserMeWithRequestID(ctx context.Context, accessToken, requestID string) (*UserMeView, error) {
227233
body, err := RequestWithId(ctx, "GET", "/safe/me", nil, accessToken, requestID)
228234
if err != nil {
229235
return nil, ServerError(ctx, err)
230236
}
231237
var resp struct {
232-
Data *User `json:"data"`
233-
Error Error `json:"error"`
238+
Data *UserMeView `json:"data"`
239+
Error Error `json:"error"`
234240
}
235241
err = json.Unmarshal(body, &resp)
236242
if err != nil {
@@ -242,11 +248,11 @@ func UserMeWithRequestID(ctx context.Context, accessToken, requestID string) (*U
242248
return resp.Data, nil
243249
}
244250

245-
func UserMe(ctx context.Context, accessToken string) (*User, error) {
251+
func UserMe(ctx context.Context, accessToken string) (*UserMeView, error) {
246252
return UserMeWithRequestID(ctx, accessToken, UuidNewV4().String())
247253
}
248254

249-
func RequestUserMe(ctx context.Context, su *SafeUser) (*User, error) {
255+
func RequestUserMe(ctx context.Context, su *SafeUser) (*UserMeView, error) {
250256
path := "/safe/me"
251257
token, err := SignAuthenticationToken("GET", path, "", su)
252258
if err != nil {

0 commit comments

Comments
 (0)