-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Add social sign in functionality (Google, Facebook, Twitter) #2155
Changes from 6 commits
deb3b22
4526f6b
3b331c5
4750563
56c77d2
a5f5d05
9479161
d86a0ea
26c6426
01c26f3
3b3a9a8
3d71ee9
0dab5e1
7fbae52
d471568
91de8e5
1e80d28
e6145ab
12f4161
29bd005
00bd03a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,24 +36,32 @@ | |
<%_ if (websocket == 'spring-websocket') { _%> | ||
"sockjs-client": "1.0.3", | ||
"stomp-websocket": "2.3.4", | ||
<%_ } _%> <%_ if (enableSocialSignIn) { _%> | ||
"bootstrap-social": "4.10.1", | ||
<%_ } _%> | ||
"font-awesome": "4.4.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding font-awesome is probably going to add a lot of resources, at the moment we only use "normal" bootstrap -> the idea is that we provide something "light" by default, but it's easy for people to extend (just do a Bower install). Can you remove this, and add the Bootstrap class instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, two options:
Wich one you prefer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally we use icons from Bootstrap, have a look at http://getbootstrap.com/components/
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No there are no brand icon on bootstrap icon set :(. I will remove font-awesome, and add to the documentation how to add the icon on the button. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jdubois I remove the font-awesome, but there is a problem, the social button is not compatible without icon. I can just create a simple bootstrap button, but we loose the user experience. On all the website it's the same type of button (icon and color). My opinion it's keep font-awesome, I think the ratio weight/utility is good, like you said it's add more ressource but allow user to use more icons and some special effect like loading icon. I prefer to keep it for a better user experience. But if you prefer to not use it I can just create a simple button with the label. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for Font Awesome, even if it's only included when someone wants social
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it's good to use Font Awesome, that's what I use for the main JHipster website :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"swagger-ui": "2.1.2" | ||
}, | ||
"devDependencies": { | ||
"angular-mocks": "1.4.5", | ||
"angular-scenario": "1.4.5" | ||
}, | ||
<%_ if (!useSass) { _%> | ||
"overrides": { | ||
<%_ if (!useSass) { _%> | ||
"bootstrap": { | ||
"main": [ | ||
"dist/js/bootstrap.js", | ||
"dist/css/bootstrap.css", | ||
"less/bootstrap.less" | ||
] | ||
}, | ||
<%_ } _%> | ||
"font-awesome": { | ||
"main": [ | ||
"css/font-awesome.css" | ||
] | ||
} | ||
}, | ||
<%_ } _%> | ||
"resolutions": { | ||
"angular": "1.4.5", | ||
"angular-cookies": "1.4.5", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package <%=packageName%>.social; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.social.connect.Connection; | ||
import org.springframework.social.connect.web.ProviderSignInUtils; | ||
import org.springframework.social.support.URIBuilder; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.CookieValue; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.context.request.WebRequest; | ||
import org.springframework.web.servlet.view.RedirectView; | ||
|
||
import javax.inject.Inject; | ||
|
||
@Controller | ||
@RequestMapping("/social") | ||
public class SocialController { | ||
private final Logger log = LoggerFactory.getLogger(SocialController.class); | ||
|
||
@Inject | ||
private SocialService socialService; | ||
|
||
@Inject | ||
private ProviderSignInUtils providerSignInUtils; | ||
|
||
@RequestMapping(value = "/signup", method = RequestMethod.GET) | ||
public RedirectView signUp(WebRequest webRequest, @CookieValue("NG_TRANSLATE_LANG_KEY") String langKey) { | ||
try { | ||
final Connection<?> connection = providerSignInUtils.getConnectionFromSession(webRequest); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not the only place, you have lots of "final" keywords, they don't do anything and add more code -> can you remove them? So it's consistent with the rest of the code, which doesn't use them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes sure! |
||
socialService.createSocialUser(connection, langKey.replace("\"", "")); | ||
return new RedirectView(URIBuilder.fromUri("/#/social-register/" + connection.getKey().getProviderId()) | ||
.queryParam("success", "true") | ||
.build().toString(), true); | ||
} catch (Exception e) { | ||
log.error("Exception creating social user: ", e); | ||
return new RedirectView(URIBuilder.fromUri("/#/social-register/no-provider") | ||
.queryParam("success", "false") | ||
.build().toString(), true); | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't put this in the end, but after the security question, so we have all the authentication questions at the same place.
Besides, does this work with the 3 different authent mechanisms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the number 4 position?
I only test with the default one, I will test it!