replyGetCreds returns user's credentials such as email and phone numbers.
(sess *Session, asUid types.Uid, msg *ClientComMessage)
| 2997 | |
| 2998 | // replyGetCreds returns user's credentials such as email and phone numbers. |
| 2999 | func (t *Topic) replyGetCreds(sess *Session, asUid types.Uid, msg *ClientComMessage) error { |
| 3000 | now := types.TimeNow() |
| 3001 | id := msg.Id |
| 3002 | |
| 3003 | if t.cat != types.TopicCatMe { |
| 3004 | sess.queueOut(ErrOperationNotAllowedReply(msg, now)) |
| 3005 | return errors.New("invalid topic category for getting credentials") |
| 3006 | } |
| 3007 | |
| 3008 | screds, err := store.Users.GetAllCreds(asUid, "", false) |
| 3009 | if err != nil { |
| 3010 | sess.queueOut(decodeStoreErrorExplicitTs(err, id, msg.Original, now, msg.Timestamp, nil)) |
| 3011 | return err |
| 3012 | } |
| 3013 | |
| 3014 | if len(screds) > 0 { |
| 3015 | creds := make([]*MsgCredServer, len(screds)) |
| 3016 | for i, sc := range screds { |
| 3017 | creds[i] = &MsgCredServer{Method: sc.Method, Value: sc.Value, Done: sc.Done} |
| 3018 | } |
| 3019 | sess.queueOut(&ServerComMessage{ |
| 3020 | Meta: &MsgServerMeta{ |
| 3021 | Id: id, |
| 3022 | Topic: t.original(asUid), |
| 3023 | Timestamp: &now, |
| 3024 | Cred: creds, |
| 3025 | }, |
| 3026 | }) |
| 3027 | return nil |
| 3028 | } |
| 3029 | |
| 3030 | // Inform the requester that there are no credentials. |
| 3031 | sess.queueOut(NoContentParamsReply(msg, now, map[string]string{"what": "creds"})) |
| 3032 | |
| 3033 | return nil |
| 3034 | } |
| 3035 | |
| 3036 | // replySetCred adds or validates user credentials such as email and phone numbers. |
| 3037 | func (t *Topic) replySetCred(sess *Session, asUid types.Uid, authLevel auth.Level, msg *ClientComMessage) error { |
no test coverage detected