diff --git a/notifications/notifications.go b/notifications/notifications.go index 7cb397226c922748b127630f5c9036aa356f4d63..98b89cf51f4029da3c6c6eac10d09531fd421f73 100644 --- a/notifications/notifications.go +++ b/notifications/notifications.go @@ -204,6 +204,10 @@ func pollForNotifications(nb *Impl) (strings []string, e error) { // RegisterForNotifications is called by the client, and adds a user registration to our database func (nb *Impl) RegisterForNotifications(clientToken []byte, auth *connect.Auth) error { + if !auth.IsAuthenticated { + return errors.New("Cannot register for notifications: client is not authenticated") + } + // Implement this u := &storage.User{ Id: auth.Sender.GetId(), @@ -218,6 +222,10 @@ func (nb *Impl) RegisterForNotifications(clientToken []byte, auth *connect.Auth) // UnregisterForNotifications is called by the client, and removes a user registration from our database func (nb *Impl) UnregisterForNotifications(auth *connect.Auth) error { + if !auth.IsAuthenticated { + return errors.New("Cannot unregister for notifications: client is not authenticated") + } + err := nb.Storage.DeleteUser(auth.Sender.GetId()) if err != nil { return errors.Wrap(err, "Failed to unregister user with notifications")