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

Twitter Signup Not working due to required Email property in User.java #3511

Closed
RawSanj opened this issue May 1, 2016 · 1 comment
Closed

Comments

@RawSanj
Copy link
Contributor

RawSanj commented May 1, 2016

Overview of the issue

Twitter Signup Not working due to Email property marked as @NotNull and @Column(length = 100, unique = true, nullable = false) (nullable = false) in User.java

Motivation for or Use Case

Social Login via Twitter.

Twitter doesn't provide email address (it requires extra permission to acquire Users Email address).
Now that Email is set to required in User.java it breaks the Twitter signup even though the Twitter application keys I used has rights to access Email address.

Email wasn't required property in version 2.x.

JHipster Version(s)

Version 3.1

JHipster configuration, a .yo-rc.json file generated in the root folder
    {
      "generator-jhipster": {
        "jhipsterVersion": "3.1.0",
        "baseName": "elasticDemo",
        "packageName": "com.rawsanj.elasticdemo",
        "packageFolder": "com/rawsanj/elasticdemo",
        "serverPort": "8080",
        "authenticationType": "session",
        "hibernateCache": "ehcache",
        "clusteredHttpSession": "no",
        "websocket": "spring-websocket",
        "databaseType": "sql",
        "devDatabaseType": "h2Disk",
        "prodDatabaseType": "postgresql",
        "searchEngine": "elasticsearch",
        "buildTool": "maven",
        "enableSocialSignIn": true,
        "rememberMeKey": "89829322c4d9c6e9418c8d49c44e9e057cea6f73",
        "useSass": false,
        "applicationType": "monolith",
        "testFrameworks": [
          "gatling"
        ],
        "jhiPrefix": "jhi",
        "enableTranslation": true,
        "nativeLanguage": "en",
        "languages": [
          "en",
          "hi"
        ]
      }
    }
Entity configuration(s) entityName.json files generated in the .jhipster directory

Not relevant.

Browsers and Operating System

Chrome and Windows 10.

Reproduce the error
  1. Create JHipster app with Social Login.
  2. Register app in Twitter with evelated rights for User's Email access.
  3. Run the application and signup using Twitter.
Related issues

#2674
#3167

Suggest a Fix

Change below code in _User.java

    @NotNull 
    @Email 
    @Size(max = 100)<% if (databaseType == 'sql') { %> 
    @Column(length = 100, unique = true, nullable = false)<% } %> 
    private String email;

to previous 2.x version code:

    @Email 
    @Size(max = 100)<% if (databaseType == 'sql') { %> 
    @Column(length = 100, unique = true)<% } %> 
    private String email;

Refer this _User.java in v3.1 and _User.java in v2.x

If making Email required is not adding much and it is breaking Twitter login then I think Email should be allowed to have Null value.
There is an Open Issue regarding retrieving Email address of User from Twitter - Get Email Issue and a ugly workaround here 😆 to get Email.
So it would be great if Email remains Nullable.

@jdubois
Copy link
Member

jdubois commented May 2, 2016

Yes I agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants