Fix error checks in provisioning API login

This commit is contained in:
Tulir Asokan 2021-02-07 16:54:09 +02:00
parent 1583ccd013
commit 1a6fdf565e

View file

@ -362,13 +362,13 @@ func (prov *ProvisioningAPI) Login(w http.ResponseWriter, r *http.Request) {
qrChan <- "stop"
if err != nil {
var msg string
if err == whatsapp.ErrAlreadyLoggedIn {
if errors.Is(err, whatsapp.ErrAlreadyLoggedIn) {
msg = "You're already logged in"
} else if err == whatsapp.ErrLoginInProgress {
} else if errors.Is(err, whatsapp.ErrLoginInProgress) {
msg = "You have a login in progress already."
} else if err == whatsapp.ErrLoginTimedOut {
} else if errors.Is(err, whatsapp.ErrLoginTimedOut) {
msg = "QR code scan timed out. Please try again."
} else if err == whatsapp.ErrInvalidWebsocket {
} else if errors.Is(err, whatsapp.ErrInvalidWebsocket) {
msg = "WhatsApp connection error. Please try again."
user.Disconnect()
} else {