Skip to content

Commit 1239af7

Browse files
liveHarshitiamareebjamal
authored andcommitted
feat: Verify email with app (#2037)
1 parent b7287ef commit 1239af7

File tree

12 files changed

+56
-13
lines changed

12 files changed

+56
-13
lines changed

app/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ android {
3737
minifyEnabled true
3838
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3939
buildConfigField "String", "DEFAULT_BASE_URL", '"https://api.eventyay.com/v1/"'
40-
buildConfigField "String", "FRONTEND_URL", '"https://eventyay.com/"'
4140
buildConfigField "String", "MAPBOX_KEY", '"'+MAPBOX_KEY+'"'
4241
buildConfigField "String", "STRIPE_API_KEY", '"'+STRIPE_API_TOKEN+'"'
4342
resValue "string", "FRONTEND_HOST", "eventyay.com"
4443
}
4544
debug {
4645
buildConfigField "String", "DEFAULT_BASE_URL", '"https://open-event-api-dev.herokuapp.com/v1/"'
47-
buildConfigField "String", "FRONTEND_URL", '"https://fossasia.github.io/open-event-frontend/"'
4846
buildConfigField "String", "MAPBOX_KEY", '"'+MAPBOX_KEY+'"'
4947
buildConfigField "String", "STRIPE_API_KEY", '"'+STRIPE_API_TOKEN+'"'
50-
resValue "string", "FRONTEND_HOST", "fossasia.github.io/open-event-frontend"
48+
resValue "string", "FRONTEND_HOST", "open-event-fe.netlify.com"
5149
}
5250
}
5351

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434

3535
<data
3636
android:scheme="https"
37-
android:host="@string/FRONTEND_HOST"
38-
android:pathPrefix="/e/" />
37+
android:host="@string/FRONTEND_HOST"/>
3938
</intent-filter>
4039
</activity>
4140
<provider
@@ -45,7 +44,7 @@
4544
android:grantUriPermissions="true">
4645
<meta-data
4746
android:name="android.support.FILE_PROVIDER_PATHS"
48-
android:resource="@xml/file_provider"/>
47+
android:resource="@xml/file_provider" />
4948
</provider>
5049
<service
5150
android:name="org.fossasia.openevent.general.order.invoice.DownloadInvoiceService"

app/src/main/java/org/fossasia/openevent/general/MainActivity.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import org.koin.androidx.viewmodel.ext.android.viewModel
2020

2121
const val PLAY_STORE_BUILD_FLAVOR = "playStore"
2222
const val EVENT_IDENTIFIER = "eventIdentifier"
23+
const val VERIFICATION_TOKEN = "verificationToken"
24+
private const val VERIFY = "verify"
25+
private const val TOKEN = "token"
2326

2427
class MainActivity : AppCompatActivity() {
2528
private lateinit var navController: NavController
@@ -52,8 +55,13 @@ class MainActivity : AppCompatActivity() {
5255
val appLinkData = intent?.data
5356
if (appLinkData != null) {
5457
val bundle = Bundle()
55-
bundle.putString(EVENT_IDENTIFIER, appLinkData.lastPathSegment)
56-
navController.navigate(R.id.eventDetailsFragment, bundle)
58+
if (appLinkData.lastPathSegment == VERIFY) {
59+
bundle.putString(VERIFICATION_TOKEN, appLinkData.getQueryParameter(TOKEN))
60+
navController.navigate(R.id.profileFragment, bundle)
61+
} else {
62+
bundle.putString(EVENT_IDENTIFIER, appLinkData.lastPathSegment)
63+
navController.navigate(R.id.eventDetailsFragment, bundle)
64+
}
5765
}
5866
}
5967

app/src/main/java/org/fossasia/openevent/general/auth/AuthApi.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ interface AuthApi {
3939
fun checkEmail(@Body email: Email): Single<CheckEmailResponse>
4040

4141
@POST("auth/resend-verification-email")
42-
fun resendVerificationEmail(@Body requestToken: RequestToken): Single<ResendVerificationEmailResponse>
42+
fun resendVerificationEmail(@Body requestToken: RequestToken): Single<EmailVerificationResponse>
43+
44+
@POST("auth/verify-email")
45+
fun verifyEmail(@Body requestEmailVerification: RequestEmailVerification): Single<EmailVerificationResponse>
4346
}

app/src/main/java/org/fossasia/openevent/general/auth/AuthService.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ class AuthService(
9898
return authApi.checkEmail(Email(email))
9999
}
100100

101-
fun resendVerificationEmail(email: String): Single<ResendVerificationEmailResponse> {
101+
fun resendVerificationEmail(email: String): Single<EmailVerificationResponse> {
102102
return authApi.resendVerificationEmail(RequestToken(Email(email)))
103103
}
104+
105+
fun verifyEmail(token: String): Single<EmailVerificationResponse> {
106+
return authApi.verifyEmail(RequestEmailVerification(Token(token)))
107+
}
104108
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package org.fossasia.openevent.general.auth
22

3-
class ResendVerificationEmailResponse(
3+
class EmailVerificationResponse(
44
val message: String? = null
55
)

app/src/main/java/org/fossasia/openevent/general/auth/ProfileFragment.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import org.fossasia.openevent.general.CircleTransform
4040
import org.fossasia.openevent.general.PLAY_STORE_BUILD_FLAVOR
4141
import org.fossasia.openevent.general.R
4242
import org.fossasia.openevent.general.BottomIconDoubleClick
43+
import org.fossasia.openevent.general.VERIFICATION_TOKEN
4344
import org.fossasia.openevent.general.utils.Utils
4445
import org.fossasia.openevent.general.utils.Utils.requireDrawable
4546
import org.fossasia.openevent.general.utils.extensions.nonNull
@@ -92,6 +93,10 @@ class ProfileFragment : Fragment(), BottomIconDoubleClick {
9293
profileViewModel.syncProfile()
9394
}
9495

96+
val token = arguments?.getString(VERIFICATION_TOKEN)
97+
if (token != null)
98+
profileViewModel.verifyProfile(token)
99+
95100
val progressDialog = progressDialog(context, getString(R.string.loading_message))
96101
profileViewModel.progress
97102
.nonNull()

app/src/main/java/org/fossasia/openevent/general/auth/ProfileViewModel.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ class ProfileViewModel(private val authService: AuthService, private val resourc
9595
}
9696
}
9797

98+
fun verifyProfile(token: String) {
99+
compositeDisposable += authService.verifyEmail(token)
100+
.withDefaultSchedulers()
101+
.doOnSubscribe {
102+
mutableProgress.value = true
103+
}.doFinally {
104+
mutableProgress.value = false
105+
}.subscribe({
106+
mutableMessage.value = it.message
107+
syncProfile()
108+
}) {
109+
Timber.e(it, "Error in verifying email")
110+
mutableMessage.value = resource.getString(R.string.verification_error_message)
111+
}
112+
}
113+
98114
override fun onCleared() {
99115
super.onCleared()
100116
compositeDisposable.clear()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package org.fossasia.openevent.general.auth
2+
3+
data class RequestEmailVerification(val data: Token)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package org.fossasia.openevent.general.auth
2+
3+
data class Token(val token: String)

0 commit comments

Comments
 (0)