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