Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change password #344

Merged
merged 4 commits into from
Oct 3, 2018
Merged
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
30 changes: 17 additions & 13 deletions app/src/main/assets/json/server-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"Get_reminded_about_this_project": "Get reminded about this project?",
"Go_to_project_page": "Go to project page",
"Got_it": "Got it",
"Got_it_your_changes_have_been_saved": "Got it! Your changes have been saved.",
"Got_it_your_survey_response_has_been_submitted": "Got it! Your survey response has been submitted.",
"Happening_newsletter": "Sign up to receive a mix of new projects, compelling stories, and visual inspiration, delivered once (and sometimes twice) a week.",
"Help": "Help",
Expand Down Expand Up @@ -2193,7 +2194,7 @@
"Email": "E-Mail",
"Email_frequency": "Häufigkeit der E-Mails",
"Email_notifications": "Benachrichtigung per E-Mail",
"Email_unverified": "This email address is unverified.",
"Email_unverified": "Diese E-Mail-Adresse wurde noch nicht verifiziert.",
"Ending_soon": "Endet bald",
"Expands_subcategories": "Erweitert die Anzeige der Unterkategorien.",
"Expired_date_at_time": "Abgelaufen am %{date} um %{time}",
Expand Down Expand Up @@ -2262,6 +2263,7 @@
"Get_reminded_about_this_project": "Möchtest du an dieses Projekt erinnert werden?",
"Go_to_project_page": "Zu Projektseite",
"Got_it": "Alles klar!",
"Got_it_your_changes_have_been_saved": "Got it! Your changes have been saved.",
"Got_it_your_survey_response_has_been_submitted": "Alles klar! Deine Antwort auf die Befragung wurde übermittelt.",
"Happening_newsletter": "Abonniere diesen Newsletter und du bekommst ein- oder zweimal die Woche einen interessanten Mix aus neuen Projekten, Stories und visueller Inspiration.",
"Help": "Hilfe",
Expand All @@ -2279,7 +2281,7 @@
"hours_plural": "Std",
"Id_just_like_to_support_the_project": "Ich möchte das Projekt einfach nur unterstützen.",
"If_you_turn_following_off": "Wenn du diese Funktion abwählst, kannst du niemandem mehr folgen und es wird dir auch niemand folgen können. Dein Profil wird den Leuten, denen du gefolgt bist, nicht mehr angezeigt. Dies kann nicht rückgängig gemacht werden.",
"If_your_profile_is_private": "Wenn dein Profil privat ist, sind dein Namen und dein Profilbild für Andere sichtbar.\n\nWenn dein Profil nicht privat ist, sind außerdem die Projekte, die du unterstützt hast, deine Biografie und deine Websites für Andere sichtbar.",
"If_your_profile_is_private": "Wenn dein Profil privat ist, sind dein Namen und dein Profilbild für Andere sichtbar.",
"If_your_profile_is_public": "Wenn dein Profil nicht privat ist, sind außerdem die Projekte, die du unterstützt hast, dein Standort, deine Biografie und deine Websites für Andere sichtbar.",
"Individual_Emails": "Individuelle E-Mails",
"Info": "Info",
Expand Down Expand Up @@ -2452,7 +2454,7 @@
"Replay_past_live_stream": "Wiedergabe des vorigen Live-Streams",
"Replay_past_live_streams": "Wiedergabe vergangener Live-Streams",
"Reply_to_user_name": "%{user_name} antworten …",
"Resend_verification_email": "Re-send verification email",
"Resend_verification_email": "Verifizierungs-E-Mail erneut senden",
"Request_my_personal_data": "Meine persönlichen Daten anfordern",
"Reward_delivered": "Belohnung versandt?",
"Reward_estimated_for_delivery_in_date": "Voraussichtliche Lieferung der <b>Belohnung</b> im %{delivery_date}",
Expand Down Expand Up @@ -2563,7 +2565,7 @@
"Upcoming_with_creator_name": "Demnächst: Video von <br/><b>%{creator_name}</b>",
"Update_pledge": "Beitrag aktualisieren",
"Use_this_to_keep_track_of_which_rewards_youve_received": "Hier kannst du nachverfolgen, welche Belohnungen du bereits erhalten hast.",
"Verification_email_sent": "We've just sent you a verification email. Click the link in it and your address will be verified.",
"Verification_email_sent": "Wir haben dir gerade eine Bestätigungs-E-Mail geschickt. Bitte klicke auf den Link in der E-Mail, um deine Adresse zu bestätigen.",
"via_custom": "Benutzerdefiniert",
"via_external": "Extern",
"via_kickstarter": "über Kickstarter",
Expand Down Expand Up @@ -4321,6 +4323,7 @@
"Get_reminded_about_this_project": "¿Deseas recibir recordatorios sobre este proyecto?",
"Go_to_project_page": "Ir a la página de proyecto",
"Got_it": "¡Listo!",
"Got_it_your_changes_have_been_saved": "Got it! Your changes have been saved.",
"Got_it_your_survey_response_has_been_submitted": "¡Listo! Hemos recibido tus respuestas a nuestro cuestionario.",
"Happening_newsletter": "Suscríbete para recibir una combinación de nuevos proyectos, historias persuasivas e inspiración visual, que se entregan una vez (y algunas veces dos veces) por semana.",
"Help": "Ayuda",
Expand All @@ -4338,7 +4341,7 @@
"hours_plural": "horas",
"Id_just_like_to_support_the_project": "Sólo quiero apoyar este proyecto.",
"If_you_turn_following_off": "Si desactivas el seguimiento, no podrás seguir a nadie y nadie podrá seguirte. Tu perfil se desconectará de todos tus seguidores. Esto no se puede deshacer.",
"If_your_profile_is_private": "Si tu perfil es privado, otros usuarios podrán ver tu nombre e imagen.\n\nSi tu perfil no es privado, otros usuarios también podrán ver los proyectos que has patrocinado, tu ubicación, biografía y sitios web.",
"If_your_profile_is_private": "Si tu perfil es privado, otros usuarios podrán ver tu nombre e imagen.\n",
"If_your_profile_is_public": "Si tu perfil no es privado, otros usuarios también podrán ver los proyectos que has patrocinado, tu ubicación, biografía y sitios web.",
"Individual_Emails": "Notificaciones por correo electrónico individuales",
"Info": "Información",
Expand Down Expand Up @@ -6311,7 +6314,7 @@
"Email": "E-mail",
"Email_frequency": "Fréquence d'envoi des e-mails",
"Email_notifications": "Notifications par e-mail",
"Email_unverified": "This email address is unverified.",
"Email_unverified": "Adresse e-mail non vérifiée.",
"Ending_soon": "Campagnes bientôt terminées",
"Expands_subcategories": "Développe les sous-catégories.",
"Expired_date_at_time": "Expirées depuis le %{date} à %{time}",
Expand Down Expand Up @@ -6380,6 +6383,7 @@
"Get_reminded_about_this_project": "Envie de recevoir un rappel à propos de ce projet ?",
"Go_to_project_page": "Accéder à la page de projet",
"Got_it": "Super.",
"Got_it_your_changes_have_been_saved": "Got it! Your changes have been saved.",
"Got_it_your_survey_response_has_been_submitted": "Merci ! Vos réponses au questionnaire ont bien été envoyées.",
"Happening_newsletter": "Inscrivez-vous pour recevoir une sélection de nouveaux projets, de témoignages et d'inspiration visuelle, une fois par semaine (et parfois deux).",
"Help": "Aide",
Expand Down Expand Up @@ -6570,7 +6574,7 @@
"Replay_past_live_stream": "Rediffusion",
"Replay_past_live_streams": "Revoir des diffusions en direct passées",
"Reply_to_user_name": "Répondre à %{user_name}…",
"Resend_verification_email": "Re-send verification email",
"Resend_verification_email": "Renvoyer l'e-mail de vérification",
"Request_my_personal_data": "Demander mes données personnelles",
"Reward_delivered": "Récompense livrée ?",
"Reward_estimated_for_delivery_in_date": "<b>Récompense</b> prévue pour %{delivery_date}",
Expand Down Expand Up @@ -6681,7 +6685,7 @@
"Upcoming_with_creator_name": "<br/><b>%{creator_name}</b> bientôt en direct",
"Update_pledge": "Modifier mon engagement",
"Use_this_to_keep_track_of_which_rewards_youve_received": "Utilisez cette fonction pour garder une trace des récompenses que vous avez reçues.",
"Verification_email_sent": "We've just sent you a verification email. Click the link in it and your address will be verified.",
"Verification_email_sent": "Nous venons de vous envoyer un e-mail de vérification. Cliquez sur le lien qu'il contient pour vérifier votre adresse.",
"via_custom": "sites référents personnalisés",
"via_external": "sites référents externes",
"via_kickstarter": "Kickstarter",
Expand Down Expand Up @@ -8370,7 +8374,7 @@
"Email": "メールアドレス",
"Email_frequency": "通知頻度",
"Email_notifications": "メール通知設定",
"Email_unverified": "This email address is unverified.",
"Email_unverified": "このメールアドレスは認証されていません。",
"Ending_soon": "終了直前",
"Expands_subcategories": "サブカテゴリーを表示",
"Expired_date_at_time": "有効期限: %{date} %{time}",
Expand Down Expand Up @@ -8439,6 +8443,7 @@
"Get_reminded_about_this_project": "このプロジェクトについてリマインダーを希望しますか?",
"Go_to_project_page": "プロジェクトページを見る",
"Got_it": "完了",
"Got_it_your_changes_have_been_saved": "Got it! Your changes have been saved.",
"Got_it_your_survey_response_has_been_submitted": "サーベイを送信しました!",
"Happening_newsletter": "新しいプロジェクトや、感動的なストーリー、視覚的なインスピレーションなどが週に1回 (時には2回) 届くニュースレターにサインアップしましょう。",
"Help": "ヘルプ",
Expand Down Expand Up @@ -8629,7 +8634,7 @@
"Replay_past_live_stream": "過去のライブ配信をリプレイ",
"Replay_past_live_streams": "過去のライブ配信をリプレイ",
"Reply_to_user_name": "%{user_nameに返信",
"Resend_verification_email": "Re-send verification email",
"Resend_verification_email": "認証メールをもう一度送信",
"Request_my_personal_data": "自分の個人データをリクエストする",
"Reward_delivered": "リワードを受け取りましたか?",
"Reward_estimated_for_delivery_in_date": "<b>リワード</b>の配達予定日は%{delivery_date}",
Expand Down Expand Up @@ -8740,7 +8745,7 @@
"Upcoming_with_creator_name": "<br/><b>%{creator_name}</b>が近日配信",
"Update_pledge": "プレッジをアップデートする",
"Use_this_to_keep_track_of_which_rewards_youve_received": "受け取ったリワードを確認するにはこちらをご利用ください。",
"Verification_email_sent": "We've just sent you a verification email. Click the link in it and your address will be verified.",
"Verification_email_sent": "認証メールを送信しました。メール内のリンクをクリックすればメールアドレスが認証済みとなります。",
"via_custom": "リファラー経由",
"via_external": "外部を経由",
"via_kickstarter": "kickstarterを経由",
Expand Down Expand Up @@ -10493,8 +10498,7 @@
"new_project_header": "experimental",
"telegraf_proxy": "experimental",
"telegraf_checkout": "experimental",
"stripe_elements_sepa": "experimental",
"es5_woe_location_search": "control"
"stripe_elements_sepa": "control"
},
"stripe": {
"publishable_key": "pk_live_zjuK52lEUYcvBhIXEUnOEJzk"
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/graphql/userprivacy.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ mutation UpdateUserEmail($email: Email!, $current_password: String!) {
}
}
}

mutation UpdateUserPassword($current_password: String!, $password: String!, $password_confirmation: String!) {
updateUserAccount(input: {current_password: $current_password, password: $password, password_confirmation: $password_confirmation}) {
user {
email
}
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/kickstarter/ApplicationModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static ApiClientType provideApiClientType(final @NonNull ApiService apiService,
@Singleton
@NonNull
static ApolloClient provideApolloClient(final @NonNull Build build, final @NonNull HttpLoggingInterceptor httpLoggingInterceptor,
final @NonNull GraphQLInterceptor graphQLInterceptor) {
final @NonNull GraphQLInterceptor graphQLInterceptor, @NonNull @WebEndpoint final String webEndpoint) {

final OkHttpClient.Builder builder = new OkHttpClient.Builder()
.addInterceptor(graphQLInterceptor);
Expand All @@ -174,7 +174,7 @@ static ApolloClient provideApolloClient(final @NonNull Build build, final @NonNu
final OkHttpClient okHttpClient = builder.build();

return ApolloClient.builder()
.serverUrl("https://www.kickstarter.com/graph")
.serverUrl(webEndpoint + "/graph")
.addCustomTypeAdapter(CustomType.EMAIL, new EmailAdapter())
.okHttpClient(okHttpClient)
.build();
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/kickstarter/extensions/ActivityExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.kickstarter.extensions

import android.app.Activity
import android.content.Intent
import android.support.design.widget.Snackbar
import android.view.View
import com.kickstarter.R

fun Activity.startActivityWithSlideUpTransition(intent: Intent) {
Expand All @@ -13,3 +15,19 @@ fun Activity.startActivityWithSlideLeftTransition(intent: Intent) {
this.startActivity(intent)
this.overridePendingTransition(R.anim.slide_in_right, R.anim.fade_out_slide_out_left)
}

fun Activity.showErrorSnackbar(anchor: View, stringResId: Int) {
showErrorSnackbar(anchor, getString(stringResId))
}

fun Activity.showErrorSnackbar(anchor: View, message: String) {
Snackbar.make(anchor, message, Snackbar.LENGTH_LONG).error(this).show()
}

fun Activity.showSuccessSnackbar(anchor: View, stringResId: Int) {
showSuccessSnackbar(anchor, getString(stringResId))
}

fun Activity.showSuccessSnackbar(anchor: View, message: String) {
Snackbar.make(anchor, message, Snackbar.LENGTH_LONG).success(this).show()
}
15 changes: 13 additions & 2 deletions app/src/main/java/com/kickstarter/extensions/SnackbarExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@ import android.support.v4.content.ContextCompat
import android.view.ViewGroup
import com.kickstarter.R

fun Snackbar.success(context: Context) {
fun Snackbar.adjustMargins() {
val params = this.view.layoutParams as ViewGroup.MarginLayoutParams
val grid1 = context.resources.getDimensionPixelSize(R.dimen.grid_1)
val grid2 = context.resources.getDimensionPixelSize(R.dimen.grid_2)
params.setMargins(grid1, 0, grid1, grid2)
this.view.layoutParams = params
this.view.background = ContextCompat.getDrawable(context, R.drawable.change_email_success_bg)
}

fun Snackbar.error(context: Context): Snackbar {
adjustMargins()
this.view.background = ContextCompat.getDrawable(context, R.drawable.bg_snackbar_error)
return this
}

fun Snackbar.success(context: Context): Snackbar {
adjustMargins()
this.view.background = ContextCompat.getDrawable(context, R.drawable.bg_snackbar_success)
return this
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package com.kickstarter.mock.services

import UpdateUserEmailMutation
import UpdateUserPasswordMutation
import UserPrivacyQuery
import com.kickstarter.services.ApolloClientType
import rx.Observable

open class MockApolloClient : ApolloClientType {
override fun updateUserPassword(currentPassword: String, newPassword: String, confirmPassword: String): Observable<UpdateUserPasswordMutation.Data> {
return Observable.just(UpdateUserPasswordMutation.Data(UpdateUserPasswordMutation.UpdateUserAccount("",
UpdateUserPasswordMutation.User("", "some@email.com"))))
}

override fun updateUserEmail(email: String, currentPassword: String): Observable<UpdateUserEmailMutation.Data> {
return Observable.just(UpdateUserEmailMutation.Data(UpdateUserEmailMutation.UpdateUserAccount("",
UpdateUserEmailMutation.User("", "Some Name", "some@email.com"))))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.kickstarter.services

import UpdateUserEmailMutation
import UpdateUserPasswordMutation
import UserPrivacyQuery
import rx.Observable

interface ApolloClientType {
fun updateUserEmail(email: String, currentPassword: String): Observable<UpdateUserEmailMutation.Data>

fun updateUserPassword(currentPassword: String, newPassword: String, confirmPassword: String): Observable<UpdateUserPasswordMutation.Data>

fun userPrivacy(): Observable<UserPrivacyQuery.Data>
}
}
26 changes: 26 additions & 0 deletions app/src/main/java/com/kickstarter/services/KSApolloClient.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.kickstarter.services

import UpdateUserEmailMutation
import UpdateUserPasswordMutation
import UserPrivacyQuery
import com.apollographql.apollo.ApolloCall
import com.apollographql.apollo.ApolloClient
Expand Down Expand Up @@ -34,6 +35,31 @@ class KSApolloClient(val service: ApolloClient) : ApolloClientType {
}
}

override fun updateUserPassword(currentPassword: String, newPassword: String, confirmPassword: String): Observable<UpdateUserPasswordMutation.Data> {
return Observable.defer {
val ps = PublishSubject.create<UpdateUserPasswordMutation.Data>()
service.mutate(UpdateUserPasswordMutation.builder()
.current_password(currentPassword)
.password(newPassword)
.password_confirmation(confirmPassword)
.build())
.enqueue(object : ApolloCall.Callback<UpdateUserPasswordMutation.Data>() {
override fun onFailure(exception: ApolloException) {
ps.onError(exception)
}

override fun onResponse(response: Response<UpdateUserPasswordMutation.Data>) {
if (response.hasErrors()) {
ps.onError(Exception(response.errors().first().message()))
}
ps.onNext(response.data())
ps.onCompleted()
}
})
return@defer ps
}
}

override fun userPrivacy(): Observable<UserPrivacyQuery.Data> {
return Observable.defer {
val ps = PublishSubject.create<UserPrivacyQuery.Data>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.kickstarter.ui.activities

import android.os.Bundle
import android.support.design.widget.Snackbar
import android.widget.Toast
import com.kickstarter.R
import com.kickstarter.extensions.success
import com.kickstarter.extensions.showSuccessSnackbar
import com.kickstarter.extensions.text
import com.kickstarter.libs.BaseActivity
import com.kickstarter.libs.qualifiers.RequiresActivityViewModel
Expand Down Expand Up @@ -53,9 +52,6 @@ class ChangeEmailActivity : BaseActivity<ChangeEmailViewModel.ViewModel>() {
}

private fun showSnackbar() {
val snackbar = Snackbar.make(change_email_layout, getString(R.string.Verification_email_sent),
Snackbar.LENGTH_LONG)
snackbar.success(this)
snackbar.show()
showSuccessSnackbar(change_email_layout, R.string.Verification_email_sent )
}
}
Loading