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

[WIP] Set auth language #654 #655

Merged
merged 17 commits into from
Jan 17, 2018
Merged

[WIP] Set auth language #654 #655

merged 17 commits into from
Jan 17, 2018

Conversation

Ehesp
Copy link
Member

@Ehesp Ehesp commented Nov 30, 2017

This PR gives the ability to set the language for the auth module, or use the device language. Usage is the same as the web sdk:

https://firebase.google.com/docs/auth/web/manage-users#send_a_password_reset_email

  • Set language code
  • Set language via device default
  • PR for documentation
  • Get language code
  • Updated typescript/flowtype
  • Handle dynamic apps
  • Tests

@Ehesp Ehesp changed the title [WIP] Set auth language [WIP] Set auth language #654 Nov 30, 2017
@Ehesp Ehesp self-assigned this Nov 30, 2017
@Ehesp Ehesp added the plugin: authentication Firebase Authentication label Nov 30, 2017
* @returns {*}
*/
useDeviceLanguage() {
return this._native.useDeviceLanguage();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to return here or on languageCode

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes!

* Sets the language for the auth module using the device language
* @returns {*}
*/
useDeviceLanguage() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some flow typings?

/**
* Gets/Sets the language for the app instance
*/
languageCode: string | null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @chrisbianca not sure how to do a getter/setter in TypeScript...? This works for the getter but not sure if it's moan when trying to set it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ehesp it is ok, languageCode is a read/write property, the implementation is hidden.

@compojoom
Copy link
Contributor

@ecirish - I said this on discord, but I'll note it here as well.
It seems that on ios there is an issue - probably not in our code, but it would be good to confirm where the error is.

Using auth.languageCode = 'en' - would sent a firebase email in english. But using auth().useDeviceLanguage() would default to firebase's project default and not the device language.

On Android this seems to behave correctly. It would be good if someone else tests useDeviceLanguage() on iOS as well before we merge this.

@Ehesp
Copy link
Member Author

Ehesp commented Dec 7, 2017

If that is the case, it seems as though it's a Firebase issue? The code on our end is quite simple:

[[FIRAuth authWithApp:firApp] useAppLanguage];

I'll try and confirm this, but if it is different to Android then we have another discepancy.

@compojoom
Copy link
Contributor

I know it seems to be a firebase issue and if it really is - then we can add it to the notes and also submit a bug report to firebase. If we just ship it as it is and it doesn't work, then other people will waste time on this as well :(

@Ehesp
Copy link
Member Author

Ehesp commented Jan 4, 2018

@compojoom We discussed this yesterday internally, for the time being we're just going to support languageCode, and add useDeviceLanguage as an unsupported method.

A workaround would be to use another lib to grab the device language and set it via languageCode.

@compojoom
Copy link
Contributor

Ok, so when is 3.2.1 coming out :)

* @param appName
*/
@ReactMethod
public void useDeviceLanguage(String appName) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Salakar @chrisbianca should I leave the native ones here for the time being? JS currently flags as unsupported due to Firebase issue, but no harm in them being here?

@Ehesp
Copy link
Member Author

Ehesp commented Jan 8, 2018

@compojoom can confirm the iOS issue! Just need to sort one last thing and should be ready to get merged.

@Ehesp
Copy link
Member Author

Ehesp commented Jan 16, 2018

cc @chrisbianca @Salakar All good to merge is you chaps are happy

@@ -340,6 +340,30 @@ export function nativeToJSError(code: string, message: string, additionalProps?:
return error;
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has moved to lib/utils/native.js so doesn't need to be here anymore - I assume this was from a merge?

@@ -342,6 +353,14 @@ export default class Auth extends ModuleBase {
return this._user;
}

get namespace(): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed that this is no longer required either.

@Salakar Salakar merged commit c14d929 into master Jan 17, 2018
@Salakar Salakar deleted the auth-language branch January 17, 2018 15:23
@invertase invertase deleted a comment from zoi-aoba Jan 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: authentication Firebase Authentication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants