Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Publish releases
on:
# Triggers the workflow on push when pushing to a version tag
push:
branches:
- jigar/auth-enable
tags:
- '*lantern-*'
workflow_dispatch:
Expand Down Expand Up @@ -285,20 +287,20 @@ jobs:
shasum -a 256 ${{ env.prefix }}.ipa | cut -d " " -f 1 > ${{ env.prefix }}.ipa.sha256
fi

- name: Commit
run: |
mv lantern-installer* ./lantern-binaries/
cd lantern-binaries
git config user.email "[email protected]"
git config user.name "Lantern Bot"
git add .
git commit -m "Lantern binaries for version ${{ env.version }}"
git push origin main

create-release:
uses: ./.github/workflows/prerelease-notification.yml
secrets: inherit
needs: [ determine-platform,set-version, build, push-binaries ]
with:
version: ${{ needs.set-version.outputs.prefix }}-${{ needs.set-version.outputs.version }}
platform: ${{ needs.determine-platform.outputs.platform }}
# - name: Commit
# run: |
# mv lantern-installer* ./lantern-binaries/
# cd lantern-binaries
# git config user.email "[email protected]"
# git config user.name "Lantern Bot"
# git add .
# git commit -m "Lantern binaries for version ${{ env.version }}"
# git push origin main
#
# create-release:
# uses: ./.github/workflows/prerelease-notification.yml
# secrets: inherit
# needs: [ determine-platform,set-version, build, push-binaries ]
# with:
# version: ${{ needs.set-version.outputs.prefix }}-${{ needs.set-version.outputs.version }}
# platform: ${{ needs.determine-platform.outputs.platform }}
3 changes: 3 additions & 0 deletions assets/locales/en-us.po
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ msgstr "Create Password"
msgid "by_creating_an_account"
msgstr "By Creating an Account, you agree to our"

msgid "by_clicking_continue"
msgstr "By clicking Continue, you agree to our"

msgid "confirm_email"
msgstr "Confirm Email"

Expand Down
12 changes: 11 additions & 1 deletion desktop/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ func (app *App) SendMessageToUI(service string, message interface{}) {
func (app *App) SendUpdateUserDataToUI() {
user, found := app.GetUserData(app.Settings().GetUserID())
if !found {
log.Debugf("User not found")
return
}
if user.UserLevel == "" {
Expand Down Expand Up @@ -581,10 +582,19 @@ func (app *App) fetchOrCreateUser(ctx context.Context) {
ss.SetUserFirstVisit(true)
app.proClient.RetryCreateUser(ctx, app, 5*time.Minute)
} else {
app.proClient.UpdateUserData(ctx, app)
app.FetchOrUpdateUserData(ctx)
}
}

func (app *App) FetchOrUpdateUserData(ctx context.Context) {
user, err := app.proClient.UpdateUserData(ctx, app)
if err != nil {
log.Errorf("Error updating user data: %v", err)
return
}
app.SetUserData(ctx, user.UserId, user)
}

func (app *App) fetchDeviceLinkingCode(ctx context.Context) (string, error) {
deviceName := func() string {
deviceName, _ := osversion.GetHumanReadable()
Expand Down
13 changes: 1 addition & 12 deletions desktop/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ package app
import (
"context"
"encoding/json"
"os"
"strconv"
"sync"

fcommon "github.com/getlantern/flashlight/v7/common"
"github.com/getlantern/flashlight/v7/config"
"github.com/getlantern/lantern-client/desktop/ws"
"github.com/getlantern/lantern-client/internalsdk/common"
"github.com/getlantern/lantern-client/internalsdk/protos"
Expand Down Expand Up @@ -72,14 +69,6 @@ func (s *configService) AddListener(f func(ConfigOptions)) {
}

func (app *App) sendConfigOptions() {
authEnabled := func(a *App) bool {
authEnabled := a.IsFeatureEnabled(config.FeatureAuth)
if ok, err := strconv.ParseBool(os.Getenv("ENABLE_AUTH_FEATURE")); err == nil && ok {
authEnabled = true
}
log.Debugf("DEBUG: Auth enabled: %v", authEnabled)
return authEnabled
}
ctx := context.Background()
plans, _ := app.proClient.Plans(ctx)
paymentMethods, _ := app.proClient.DesktopPaymentMethods(ctx)
Expand All @@ -93,7 +82,7 @@ func (app *App) sendConfigOptions() {
ReplicaAddr: "",
HttpProxyAddr: app.settings.GetAddr(),
SocksProxyAddr: app.settings.GetSOCKSAddr(),
AuthEnabled: authEnabled(app),
AuthEnabled: true,
ChatEnabled: false,
SplitTunneling: false,
HasSucceedingProxy: app.HasSucceedingProxy(),
Expand Down
16 changes: 15 additions & 1 deletion desktop/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func signup(email *C.char, password *C.char) *C.char {
setting.SetEmailAddress(C.GoString(email))
a.SetUserLoggedIn(true)
a.ProClient().FetchPaymentMethodsAndCache(context.Background())
a.SendConfig()
return C.CString("true")
}

Expand Down Expand Up @@ -129,9 +130,19 @@ func logout() *C.char {

clearLocalUserData()
// Create new user
if _, err := a.ProClient().UserCreate(ctx); err != nil {
userData, err := a.ProClient().UserCreate(ctx)
if err != nil {
return sendError(err)
}
//Update new user data to UI
user := userData.User
if user.UserStatus == "" {
user.UserStatus = "free"
}
setting := a.Settings()
setting.SetUserIDAndToken(user.UserId, user.Token)
setting.SetReferralCode(user.Referral)
a.SetUserData(context.Background(), user.UserId, userData.User)
return C.CString("true")
}

Expand Down Expand Up @@ -207,6 +218,9 @@ func completeRecoveryByEmail(email *C.char, code *C.char, password *C.char) *C.c
//Save new salt
saveUserSalt(newsalt)
log.Debugf("CompleteRecoveryByEmail response %v", recovery)
a.SendConfig()
a.SendUpdateUserDataToUI()

return C.CString("true")
}

Expand Down
1 change: 1 addition & 0 deletions desktop/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ func testProviderRequest(email *C.char, paymentProvider *C.char, plan *C.char) *
if err != nil {
return sendError(err)
}
go a.FetchOrUpdateUserData(ctx)
return C.CString("true")
}

Expand Down
3 changes: 2 additions & 1 deletion internalsdk/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ func run(configDir, locale string, settings Settings, wrappedSession Session) {

authEnabled := runner.FeatureEnabled(config.FeatureAuth, common.ApplicationVersion)
log.Debugf("Feature: Auth enabled? %v", authEnabled)
session.SetAuthEnabled(authEnabled)
// Make auth enable for all
session.SetAuthEnabled(true)
// Check if ads feature is enabled or not
if !session.IsProUser() {
showAdsEnabled := runner.FeatureEnabled(config.FeatureInterstitialAds, common.ApplicationVersion)
Expand Down
5 changes: 1 addition & 4 deletions internalsdk/session_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,7 @@ func (m *SessionModel) checkAvailableFeatures() {
// Check for auth feature
authEnabled := m.featureEnabled(config.FeatureAuth)
m.SetAuthEnabled(authEnabled)
platfrom, _ := m.platform()
if platfrom == "ios" {
m.SetAuthEnabled(true)
}
m.SetAuthEnabled(true)

// Check for ads feature
googleAdsEnabled := m.featureEnabled(config.FeatureInterstitialAds)
Expand Down
4 changes: 3 additions & 1 deletion lib/core/extension/error_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extension ErrorX on Object {
if (this is PlatformException) {
// Extract the message from the PlatformException
String description = (this as PlatformException).message ?? '';
print("description $description");
if (description.contains("proxy_error")) {
return "proxy_error".i18n;
}
Expand All @@ -21,7 +22,8 @@ extension ErrorX on Object {
return "recovery_not_found".i18n;
}

if (description.contains("wrong-link-code")) {
if (description.contains("wrong-link-code") ||
description.contains("wrong_device_linking_code")) {
return "wrong_link_code".i18n;
}
if (description
Expand Down
43 changes: 29 additions & 14 deletions lib/core/service/websocket_subscriber.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,39 @@ class WebsocketSubscriber {
}
case _WebsocketMessageType.pro:
_webSocketLogger.i("Websocket message[Pro]: $message");
final userStatus = message['userStatus'];
final userLevel = message['userLevel'];
final deviceLinkingCode = message['deviceLinkingCode'];
final isLevelPro = userLevel != null && userLevel == 'pro';
final isStatusPro = userStatus != null && userStatus == 'active';
sessionModel.proUserNotifier.value = (isLevelPro || isStatusPro);
if (deviceLinkingCode != null) {
sessionModel.linkingCodeNotifier.value = deviceLinkingCode;
final proMap = message as Map<String, dynamic>;

///Since pro channel has been used many places, we need to check if the key exists
/// Sometime is send only one key, sometime multiple keys if don't then values goes back to default
if (proMap.containsKey('userStatus') ||
proMap.containsKey('userLevel')) {
final userStatus = proMap['userStatus'];
final userLevel = proMap['userLevel'];
final isLevelPro = userLevel != null && userLevel == 'pro';
final isStatusPro = userStatus != null && userStatus == 'active';
sessionModel.proUserNotifier.value = (isLevelPro || isStatusPro);
}
final userSignedIn = message['login'];
if (userSignedIn != null) {
sessionModel.hasUserSignedInNotifier.value = userSignedIn as bool;

if (proMap.containsKey('deviceLinkingCode')) {
final deviceLinkingCode = proMap['deviceLinkingCode'];
if (deviceLinkingCode != null) {
sessionModel.linkingCodeNotifier.value = deviceLinkingCode;
}
}
final language = message['language'];
if (language != null) {
sessionModel.langNotifier.value = language;
if (proMap.containsKey('login')) {
final userSignedIn = proMap['login'];
if (userSignedIn != null) {
sessionModel.hasUserSignedInNotifier.value =
userSignedIn as bool;
}
}

if (proMap.containsKey('language')) {
final language = proMap['language'];
if (language != null) {
sessionModel.langNotifier.value = language;
}
}
case _WebsocketMessageType.bandwidth:
_webSocketLogger.i("Websocket message[Bandwidth]: $message");
sessionModel.bandwidthNotifier.value = Bandwidth.create()
Expand Down
13 changes: 5 additions & 8 deletions lib/core/widgtes/tos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,23 @@ import 'package:lantern/core/utils/common.dart';

class TOS extends StatelessWidget {
const TOS({
Key? key,
}) : super(key: key);
super.key,
});

@override
Widget build(BuildContext context) {
return Text.rich(
TextSpan(
children: [
TextSpan(
text: 'by_creating_an_account'.i18n,
text: 'by_clicking_continue'.i18n,
style: tsFloatingLabel,
),
const TextSpan(
text: ' ',
),
const TextSpan(text: ' '),
TextSpan(
text: 'terms_of_service'.i18n,
style: tsFloatingLabel!.copiedWith(
decoration: TextDecoration.underline,
),
decoration: TextDecoration.underline, color: onSwitchColor),
recognizer: TapGestureRecognizer()
..onTap = () => openTermsOfService(context),
),
Expand Down
7 changes: 5 additions & 2 deletions lib/features/account/account_management.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import 'package:lantern/core/utils/utils.dart';

@RoutePage(name: 'AccountManagement')
class AccountManagement extends StatefulWidget {
const AccountManagement({Key? key, required this.isPro}) : super(key: key);
const AccountManagement({super.key, required this.isPro});
final bool isPro;

@override
State<AccountManagement> createState() => _AccountManagementState();
}
Expand Down Expand Up @@ -310,6 +309,10 @@ class _AccountManagementState extends State<AccountManagement>
icon: ImagePaths.email,
content: emailAddress,
trailingArray: [],
onTap: () => copyText(
context,
emailAddress,
)
);
}),

Expand Down
27 changes: 4 additions & 23 deletions lib/features/auth/create_account_password.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import 'package:flutter/gestures.dart';
import 'package:lantern/common/ui/password_criteria.dart';
import 'package:lantern/core/utils/utils.dart';
import 'package:lantern/core/widgtes/tos.dart';
import '../../core/utils/common.dart';

@RoutePage(name: 'CreateAccountPassword')
Expand Down Expand Up @@ -62,6 +63,8 @@ class _CreateAccountPasswordState extends State<CreateAccountPassword> {
textEditingController: _passwordController,
),
const SizedBox(height: 24),
const TOS(),
const SizedBox(height: 24),
SizedBox(
width: double.infinity,
child: Button(
Expand All @@ -71,29 +74,7 @@ class _CreateAccountPasswordState extends State<CreateAccountPassword> {
),
),
const SizedBox(height: 24),
Text.rich(
TextSpan(
children: [
TextSpan(
text: 'by_creating_an_account'.i18n,
style: tsFloatingLabel,
),
const TextSpan(
text: ' ',
),
TextSpan(
text: 'terms_of_service'.i18n,
style: tsFloatingLabel!.copiedWith(
decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()
..onTap = openTermsOfService,
),
],
),
textAlign: TextAlign.center,
),
const SizedBox(height: 20),

],
),
),
Expand Down
Loading
Loading