Track referral code
This commit is contained in:
parent
d745082ead
commit
49f7616098
|
|
@ -21,10 +21,11 @@ class AuthRepository {
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<LoginResponse> signUp({
|
Future<LoginResponse> signUp({
|
||||||
String url,
|
@required String url,
|
||||||
String email,
|
@required String email,
|
||||||
String password,
|
@required String password,
|
||||||
String secret,
|
@required String secret,
|
||||||
|
@required String referralCode,
|
||||||
}) async {
|
}) async {
|
||||||
final credentials = {
|
final credentials = {
|
||||||
'email': email,
|
'email': email,
|
||||||
|
|
@ -39,12 +40,15 @@ class AuthRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
return sendRequest(
|
return sendRequest(
|
||||||
url: formatApiUrl(url) + '/signup', data: credentials, secret: secret);
|
url: formatApiUrl(url) + '/signup?rc=$referralCode',
|
||||||
|
data: credentials,
|
||||||
|
secret: secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<LoginResponse> oauthSignUp({
|
Future<LoginResponse> oauthSignUp({
|
||||||
@required String idToken,
|
@required String idToken,
|
||||||
@required String accessToken,
|
@required String accessToken,
|
||||||
|
@required String referralCode,
|
||||||
}) async {
|
}) async {
|
||||||
final credentials = {
|
final credentials = {
|
||||||
'terms_of_service': true,
|
'terms_of_service': true,
|
||||||
|
|
@ -56,7 +60,8 @@ class AuthRepository {
|
||||||
};
|
};
|
||||||
|
|
||||||
return sendRequest(
|
return sendRequest(
|
||||||
url: formatApiUrl(Constants.hostedApiUrl) + '/oauth_login?create=true',
|
url: formatApiUrl(Constants.hostedApiUrl) +
|
||||||
|
'/oauth_login?create=true&rc=$referralCode',
|
||||||
data: credentials,
|
data: credentials,
|
||||||
secret: Config.API_SECRET);
|
secret: Config.API_SECRET);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,8 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
factory AppState({
|
factory AppState({
|
||||||
@required PrefState prefState,
|
@required PrefState prefState,
|
||||||
@required bool reportErrors,
|
@required bool reportErrors,
|
||||||
@required String referralCode,
|
|
||||||
String url,
|
String url,
|
||||||
|
String referralCode,
|
||||||
String currentRoute,
|
String currentRoute,
|
||||||
}) {
|
}) {
|
||||||
return _$AppState._(
|
return _$AppState._(
|
||||||
|
|
|
||||||
|
|
@ -124,12 +124,13 @@ Middleware<AppState> _createLoginRequest(AuthRepository repository) {
|
||||||
Middleware<AppState> _createSignUpRequest(AuthRepository repository) {
|
Middleware<AppState> _createSignUpRequest(AuthRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as UserSignUpRequest;
|
final action = dynamicAction as UserSignUpRequest;
|
||||||
|
final state = store.state;
|
||||||
|
|
||||||
repository
|
repository
|
||||||
.signUp(
|
.signUp(
|
||||||
email: action.email,
|
email: action.email,
|
||||||
password: action.password,
|
password: action.password,
|
||||||
)
|
referralCode: state.authState.referralCode)
|
||||||
.then((data) {
|
.then((data) {
|
||||||
_saveAuthLocal(kAppProductionUrl);
|
_saveAuthLocal(kAppProductionUrl);
|
||||||
|
|
||||||
|
|
@ -188,12 +189,13 @@ Middleware<AppState> _createOAuthLoginRequest(AuthRepository repository) {
|
||||||
Middleware<AppState> _createOAuthSignUpRequest(AuthRepository repository) {
|
Middleware<AppState> _createOAuthSignUpRequest(AuthRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as OAuthSignUpRequest;
|
final action = dynamicAction as OAuthSignUpRequest;
|
||||||
|
final state = store.state;
|
||||||
|
|
||||||
repository
|
repository
|
||||||
.oauthSignUp(
|
.oauthSignUp(
|
||||||
accessToken: action.accessToken,
|
accessToken: action.accessToken,
|
||||||
idToken: action.idToken,
|
idToken: action.idToken,
|
||||||
)
|
referralCode: state.authState.referralCode)
|
||||||
.then((data) {
|
.then((data) {
|
||||||
_saveAuthLocal(kAppProductionUrl);
|
_saveAuthLocal(kAppProductionUrl);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ abstract class AuthState implements Built<AuthState, AuthStateBuilder> {
|
||||||
isAuthenticated: false,
|
isAuthenticated: false,
|
||||||
isInitialized: false,
|
isInitialized: false,
|
||||||
lastEnteredPasswordAt: 0,
|
lastEnteredPasswordAt: 0,
|
||||||
referralCode: referralCode,
|
referralCode: referralCode ?? '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue