File tree Expand file tree Collapse file tree
app/src/main/java/com/getcode Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,6 +86,36 @@ class AuthManager @Inject constructor(
8686 return login(entropyB64, isSoftLogin = true )
8787 }
8888
89+ fun createAccount (
90+ entropyB64 : String ,
91+ rollbackOnError : Boolean = false,
92+ ): Completable {
93+ if (entropyB64.isEmpty()) {
94+ taggedTrace(" provided entropy was empty" , type = TraceType .Error )
95+ sessionManager.clear()
96+ return Completable .complete()
97+ }
98+
99+ return Single .create {
100+ softLoginDisabled = true
101+
102+ if (! Database .isOpen()) {
103+ Database .init (context, entropyB64)
104+ }
105+
106+ val originalSessionState = SessionManager .authState.value
107+ sessionManager.set(entropyB64)
108+
109+ it.onSuccess(originalSessionState)
110+ }.flatMapCompletable {
111+ fetchAdditionalAccountData(context, entropyB64,
112+ isSoftLogin = false ,
113+ rollbackOnError = rollbackOnError,
114+ originalSessionState = it
115+ )
116+ }.doOnError { softLoginDisabled = false }
117+ }
118+
89119 fun login (
90120 entropyB64 : String ,
91121 isSoftLogin : Boolean = false,
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ class AccessKeyViewModel @Inject constructor(
3939 fun onSubmit (navigator : CodeNavigator , isSaveImage : Boolean , isDeepLink : Boolean = false) {
4040 val entropyB64 = uiFlow.value.entropyB64 ? : return
4141
42- authManager.login (entropyB64, rollbackOnError = isDeepLink)
42+ authManager.createAccount (entropyB64, rollbackOnError = isDeepLink)
4343 .observeOn(AndroidSchedulers .mainThread())
4444 .subscribeOn(Schedulers .computation())
4545 .doOnSubscribe {
You can’t perform that action at this time.
0 commit comments