Account creation
(msg *ClientComMessage)
| 880 | |
| 881 | // Account creation |
| 882 | func (s *Session) acc(msg *ClientComMessage) { |
| 883 | newAcc := strings.HasPrefix(msg.Acc.User, "new") |
| 884 | |
| 885 | // If temporary auth parameters are provided, get the user ID from them. |
| 886 | var rec *auth.Rec |
| 887 | if !newAcc && msg.Acc.TmpScheme != "" { |
| 888 | if !s.uid.IsZero() { |
| 889 | s.queueOut(ErrAlreadyAuthenticated(msg.Acc.Id, "", msg.Timestamp)) |
| 890 | logs.Warn.Println("s.acc: got temp auth while already authenticated", s.sid) |
| 891 | return |
| 892 | } |
| 893 | |
| 894 | authHdl := store.Store.GetLogicalAuthHandler(msg.Acc.TmpScheme) |
| 895 | if authHdl == nil { |
| 896 | logs.Warn.Println("s.acc: unknown authentication scheme", msg.Acc.TmpScheme, s.sid) |
| 897 | s.queueOut(ErrAuthUnknownScheme(msg.Id, "", msg.Timestamp)) |
| 898 | } |
| 899 | |
| 900 | var err error |
| 901 | rec, _, err = authHdl.Authenticate(msg.Acc.TmpSecret, s.remoteAddr) |
| 902 | if err != nil { |
| 903 | s.queueOut(decodeStoreError(err, msg.Acc.Id, msg.Timestamp, |
| 904 | map[string]any{"what": "auth"})) |
| 905 | logs.Warn.Println("s.acc: invalid temp auth", err, s.sid) |
| 906 | return |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | if newAcc { |
| 911 | // New account |
| 912 | replyCreateUser(s, msg, rec) |
| 913 | } else { |
| 914 | // Existing account. |
| 915 | replyUpdateUser(s, msg, rec) |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | // Authenticate |
| 920 | func (s *Session) login(msg *ClientComMessage) { |
nothing calls this directly
no test coverage detected