forked from Silverfish/proton-bridge
GODT-1210: "free user" banner
This commit is contained in:
@ -40,6 +40,8 @@ Popup {
|
|||||||
|
|
||||||
shouldShow: notification ? (notification.active && !notification.dismissed) : false
|
shouldShow: notification ? (notification.active && !notification.dismissed) : false
|
||||||
|
|
||||||
|
modal: false
|
||||||
|
|
||||||
Action {
|
Action {
|
||||||
id: defaultDismissAction
|
id: defaultDismissAction
|
||||||
|
|
||||||
|
|||||||
@ -129,7 +129,7 @@ ColumnLayout {
|
|||||||
text: "free user error"
|
text: "free user error"
|
||||||
enabled: user !== undefined //&& user.isLoginRequested
|
enabled: user !== undefined //&& user.isLoginRequested
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.backend.loginFreeUserError("")
|
root.backend.loginFreeUserError()
|
||||||
user.resetLoginRequests()
|
user.resetLoginRequests()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -634,7 +634,7 @@ Window {
|
|||||||
|
|
||||||
// this signals are used only when trying to login with new user (i.e. not in users model)
|
// this signals are used only when trying to login with new user (i.e. not in users model)
|
||||||
signal loginUsernamePasswordError(string errorMsg)
|
signal loginUsernamePasswordError(string errorMsg)
|
||||||
signal loginFreeUserError(string errorMsg)
|
signal loginFreeUserError()
|
||||||
signal loginConnectionError(string errorMsg)
|
signal loginConnectionError(string errorMsg)
|
||||||
signal login2FARequested()
|
signal login2FARequested()
|
||||||
signal login2FAError(string errorMsg)
|
signal login2FAError(string errorMsg)
|
||||||
|
|||||||
@ -22,6 +22,7 @@ package qt
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
|
||||||
"github.com/ProtonMail/proton-bridge/internal/users"
|
"github.com/ProtonMail/proton-bridge/internal/users"
|
||||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||||
)
|
)
|
||||||
@ -38,7 +39,11 @@ func (f *FrontendQt) login(username, password string) {
|
|||||||
|
|
||||||
f.authClient, f.auth, err = f.bridge.Login(username, f.password)
|
f.authClient, f.auth, err = f.bridge.Login(username, f.password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO login free user error
|
if err == pmapi.ErrPaidPlanRequired {
|
||||||
|
f.qml.LoginFreeUserError()
|
||||||
|
f.loginClean()
|
||||||
|
return
|
||||||
|
}
|
||||||
f.qml.LoginUsernamePasswordError(err.Error())
|
f.qml.LoginUsernamePasswordError(err.Error())
|
||||||
f.loginClean()
|
f.loginClean()
|
||||||
return
|
return
|
||||||
|
|||||||
@ -55,7 +55,7 @@ type QMLBackend struct {
|
|||||||
_ func(username, password string) `slot:"login2Password"`
|
_ func(username, password string) `slot:"login2Password"`
|
||||||
_ func(username string) `slot:"loginAbort"`
|
_ func(username string) `slot:"loginAbort"`
|
||||||
_ func(errorMsg string) `signal:"loginUsernamePasswordError"`
|
_ func(errorMsg string) `signal:"loginUsernamePasswordError"`
|
||||||
_ func(errorMsg string) `signal:"loginFreeUserError"`
|
_ func() `signal:"loginFreeUserError"`
|
||||||
_ func(errorMsg string) `signal:"loginConnectionError"`
|
_ func(errorMsg string) `signal:"loginConnectionError"`
|
||||||
_ func() `signal:"login2FARequested"`
|
_ func() `signal:"login2FARequested"`
|
||||||
_ func(errorMsg string) `signal:"login2FAError"`
|
_ func(errorMsg string) `signal:"login2FAError"`
|
||||||
|
|||||||
@ -26,6 +26,8 @@ var (
|
|||||||
|
|
||||||
ErrBad2FACode = errors.New("incorrect 2FA code")
|
ErrBad2FACode = errors.New("incorrect 2FA code")
|
||||||
ErrBad2FACodeTryAgain = errors.New("incorrect 2FA code: please try again")
|
ErrBad2FACodeTryAgain = errors.New("incorrect 2FA code: please try again")
|
||||||
|
|
||||||
|
ErrPaidPlanRequired = errors.New("paid subscription plan is required")
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrUnprocessableEntity struct {
|
type ErrUnprocessableEntity struct {
|
||||||
|
|||||||
@ -30,7 +30,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
errCodeUpgradeApplication = 5003
|
errCodeUpgradeApplication = 5003
|
||||||
|
errCodeAuthPaidPlanRequired = 10004
|
||||||
)
|
)
|
||||||
|
|
||||||
type Error struct {
|
type Error struct {
|
||||||
@ -60,6 +61,8 @@ func (m *manager) catchAPIError(_ *resty.Client, res *resty.Response) error {
|
|||||||
if m.cfg.UpgradeApplicationHandler != nil {
|
if m.cfg.UpgradeApplicationHandler != nil {
|
||||||
m.cfg.UpgradeApplicationHandler()
|
m.cfg.UpgradeApplicationHandler()
|
||||||
}
|
}
|
||||||
|
case apiErr.Code == errCodeAuthPaidPlanRequired:
|
||||||
|
err = ErrPaidPlanRequired
|
||||||
case res.StatusCode() == http.StatusUnprocessableEntity:
|
case res.StatusCode() == http.StatusUnprocessableEntity:
|
||||||
err = ErrUnprocessableEntity{apiErr}
|
err = ErrUnprocessableEntity{apiErr}
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user