Skip to content

Commit

Permalink
Desktop Username password (#1111)
Browse files Browse the repository at this point in the history
* started working on desktop username passwrord.

* Work on onboarding pro user to new flow desktop.

* added support for login and logout.

* Update account.dart

* Added some new setting and persist data

* Fixed issue UI not updating.

* Started working on reset password flow for desktop.

* Validate code on verification.

* Enable delete account flow.

* Implemented Delete flow.

* Started working on deviceLimit flow.

* Completed Device Limit flow.

* Started working on signupflow.

* Add test payment method.

* fixed issue with pro and device id.

* fixed issue with report parsing issue on reportIssue.

* Use compute in reseller code

* Update session_model.dart

* Fixed issue with salt returning null.

* Null check on srp client.

* Update user data when renew plans.

* change CI branch.

* Disable windows CI for now.

* PR review changes.

* revert CI changes

* remove commented lines

* remove commented lines

* Remove commented code.

* fixed signal issues.

* Update lib.go

* Use ParallelForIdempotent for domain fronting.

* use ParallelPreferChained proxy.

* Hide auth flow for android.

---------

Co-authored-by: atavism <[email protected]>
  • Loading branch information
jigar-f and atavism authored Jul 19, 2024
1 parent 522bb46 commit 3334ce5
Show file tree
Hide file tree
Showing 31 changed files with 1,509 additions and 507 deletions.
2 changes: 1 addition & 1 deletion assets/locales/en-us.po
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ msgstr "Cannot complete purchase"


msgid "discover_not_working"
msgstr "Discover not working "
msgstr "Discover not working"

msgid "cannot_sign_in"
msgstr "Cannot sign in"
Expand Down
24 changes: 22 additions & 2 deletions desktop/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/getlantern/profiling"

"github.com/getlantern/lantern-client/desktop/analytics"

"github.com/getlantern/lantern-client/desktop/autoupdate"
"github.com/getlantern/lantern-client/desktop/datacap"
"github.com/getlantern/lantern-client/desktop/features"
Expand Down Expand Up @@ -376,6 +377,27 @@ func (app *App) SetLanguage(lang string) {
}
}

func (app *App) SetUserLoggedIn(value bool) {
app.settings.SetUserLoggedIn(value)
if app.ws != nil {
app.ws.SendMessage("pro", map[string]interface{}{
"login": value,
})
}
}

func (app *App) IsUserLoggedIn() bool {
return app.Settings().IsUserLoggedIn()

}

// Create func that send message to UI
func (app *App) SendMessageToUI(service string, message interface{}) {
if app.ws != nil {
app.ws.SendMessage(service, message)
}
}

// OnSettingChange sets a callback cb to get called when attr is changed from server.
// When calling multiple times for same attr, only the last one takes effect.
func (app *App) OnSettingChange(attr settings.SettingName, cb func(interface{})) {
Expand Down Expand Up @@ -456,8 +478,6 @@ func (app *App) HasSucceedingProxy() bool {
}

func (app *App) GetHasConfigFetched() bool {

log.Debugf("Global config fetched: %v, Proxies config fetched: %v")
return atomic.LoadInt32(&app.fetchedGlobalConfig) == 1
}

Expand Down
28 changes: 13 additions & 15 deletions desktop/app/pro.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,25 @@ func fetchUserDataWithClient(ctx context.Context, proClient pro.ProClient, uc co
if err != nil {
return nil, err
}
setUserData(ctx, userID, resp.User)
SetUserData(ctx, userID, resp.User)
log.Debugf("User %d is '%v'", userID, resp.User.UserStatus)
return resp, nil
}

func setUserData(ctx context.Context, userID int64, user *protos.User) {
func SetUserData(ctx context.Context, userID int64, user *protos.User) {
log.Debugf("Storing user data for user %v", userID)
userData.save(ctx, userID, user)
}

func SetUserDevices(ctx context.Context, userID int64, devices []*protos.Device) {
user, found := userData.get(ctx, userID)
if !found {
return
}
user.Devices = devices
userData.save(ctx, userID, user)
}

// isActive determines whether the given status is an active status
func isActive(status string) bool {
return status == "active"
Expand All @@ -140,7 +149,7 @@ func IsProUserFast(ctx context.Context, uc common.UserConfig) (isPro bool, statu
if !found {
return false, false
}
return isActive(user.UserStatus), found
return (isActive(user.UserStatus) || user.UserLevel == "pro"), found
}

// isProUserFast checks a cached value for the pro status and doesn't wait for
Expand Down Expand Up @@ -194,18 +203,7 @@ func (app *App) servePro(channel ws.UIChannel) error {
}
}()

helloFn := func(write func(interface{})) {
if user, known := GetUserDataFast(ctx, app.settings.GetUserID()); known {
log.Debugf("Sending current user data to new client: %v", user)
write(user)
}
log.Debugf("Fetching user data again to see if any changes")
select {
case chFetch <- true:
default: // fetching in progress, skipping
}
}
service, err := channel.Register("pro", helloFn)
service, err := channel.Register("pro", nil)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 3334ce5

Please sign in to comment.