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
|
||||
|
||||
modal: false
|
||||
|
||||
Action {
|
||||
id: defaultDismissAction
|
||||
|
||||
|
||||
@ -129,7 +129,7 @@ ColumnLayout {
|
||||
text: "free user error"
|
||||
enabled: user !== undefined //&& user.isLoginRequested
|
||||
onClicked: {
|
||||
root.backend.loginFreeUserError("")
|
||||
root.backend.loginFreeUserError()
|
||||
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)
|
||||
signal loginUsernamePasswordError(string errorMsg)
|
||||
signal loginFreeUserError(string errorMsg)
|
||||
signal loginFreeUserError()
|
||||
signal loginConnectionError(string errorMsg)
|
||||
signal login2FARequested()
|
||||
signal login2FAError(string errorMsg)
|
||||
|
||||
@ -22,6 +22,7 @@ package qt
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/users"
|
||||
"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)
|
||||
if err != nil {
|
||||
// TODO login free user error
|
||||
if err == pmapi.ErrPaidPlanRequired {
|
||||
f.qml.LoginFreeUserError()
|
||||
f.loginClean()
|
||||
return
|
||||
}
|
||||
f.qml.LoginUsernamePasswordError(err.Error())
|
||||
f.loginClean()
|
||||
return
|
||||
|
||||
@ -55,7 +55,7 @@ type QMLBackend struct {
|
||||
_ func(username, password string) `slot:"login2Password"`
|
||||
_ func(username string) `slot:"loginAbort"`
|
||||
_ func(errorMsg string) `signal:"loginUsernamePasswordError"`
|
||||
_ func(errorMsg string) `signal:"loginFreeUserError"`
|
||||
_ func() `signal:"loginFreeUserError"`
|
||||
_ func(errorMsg string) `signal:"loginConnectionError"`
|
||||
_ func() `signal:"login2FARequested"`
|
||||
_ func(errorMsg string) `signal:"login2FAError"`
|
||||
|
||||
@ -26,6 +26,8 @@ var (
|
||||
|
||||
ErrBad2FACode = errors.New("incorrect 2FA code")
|
||||
ErrBad2FACodeTryAgain = errors.New("incorrect 2FA code: please try again")
|
||||
|
||||
ErrPaidPlanRequired = errors.New("paid subscription plan is required")
|
||||
)
|
||||
|
||||
type ErrUnprocessableEntity struct {
|
||||
|
||||
@ -31,6 +31,7 @@ import (
|
||||
|
||||
const (
|
||||
errCodeUpgradeApplication = 5003
|
||||
errCodeAuthPaidPlanRequired = 10004
|
||||
)
|
||||
|
||||
type Error struct {
|
||||
@ -60,6 +61,8 @@ func (m *manager) catchAPIError(_ *resty.Client, res *resty.Response) error {
|
||||
if m.cfg.UpgradeApplicationHandler != nil {
|
||||
m.cfg.UpgradeApplicationHandler()
|
||||
}
|
||||
case apiErr.Code == errCodeAuthPaidPlanRequired:
|
||||
err = ErrPaidPlanRequired
|
||||
case res.StatusCode() == http.StatusUnprocessableEntity:
|
||||
err = ErrUnprocessableEntity{apiErr}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user