forked from saurabh/orbit4-5
user sign up and facebook connection completed
This commit is contained in:
parent
5d10c13e2a
commit
b64385771a
|
@ -79,15 +79,15 @@ class FacebookController < ApplicationController
|
|||
data = JSON.parse(friends)
|
||||
if data["success"]
|
||||
user = JSON.parse(data["user"])
|
||||
u = User.find(temp_user.id)
|
||||
firstname = {}
|
||||
lastname = {}
|
||||
@site_valid_locales.each do |locale|
|
||||
firstname[locale] = user["first_name"]
|
||||
lastname[locale] = user["last_name"]
|
||||
end
|
||||
u.first_name_translations = firstname
|
||||
u.last_name_translations = lastname
|
||||
u = User.find(temp_user.id).member_profile
|
||||
# firstname = {}
|
||||
# lastname = {}
|
||||
# @site_valid_locales.each do |locale|
|
||||
# firstname[locale] = user["first_name"]
|
||||
# lastname[locale] = user["last_name"]
|
||||
# end
|
||||
# u.first_name_translations = firstname
|
||||
# u.last_name_translations = lastname
|
||||
u.office_tel = user["phone"]
|
||||
u.sex = user["gender"] || "unknown"
|
||||
u.remote_avatar_url = user["picture"] if user["picture"]
|
||||
|
@ -111,7 +111,7 @@ class FacebookController < ApplicationController
|
|||
if !@url.nil?
|
||||
redirect_to @url
|
||||
else
|
||||
render :layout=> "devise"
|
||||
render :layout=> "authentication"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,17 +10,23 @@ class UsersController < ApplicationController
|
|||
if @user.save
|
||||
@member.save
|
||||
@user.update_attributes(member_profile_id: @member.id)
|
||||
redirect_to root_url, :notice => "Signed Up Successfully, Please Check your email for confirmation!"
|
||||
@user.send_confirmation_email
|
||||
redirect_to users_confirmation_path
|
||||
@user.generate_confirmation_token
|
||||
url = "#{request.protocol}#{request.host_with_port}/#{locale.to_s}/users/confirm_user?token=#{@user.confirmation_token}"
|
||||
email = Email.new(:mail_to => @user.member_profile.email, :mail_subject => "Confirmation email for orbit signup.", :template => "email/user_confirmation_email.html.erb", :template_data => {"url" => url})
|
||||
email.deliver
|
||||
else
|
||||
render "new"
|
||||
end
|
||||
end
|
||||
|
||||
def confirmation
|
||||
end
|
||||
|
||||
def confirm_user
|
||||
user = User.confirm_email(params[:token])
|
||||
|
||||
redirect_to users_path(:user_id => user.id.to_s)
|
||||
redirect_to users_path(:user_id => user[:id])
|
||||
if user[:success].eql?("true")
|
||||
flash[:notice] = "You have confirmed successfully"
|
||||
else
|
||||
|
@ -51,19 +57,17 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def role_page
|
||||
@roles = []
|
||||
# @roles = Role.where(:disabled => false)
|
||||
@roles = Role.where(:disabled => false)
|
||||
@user_id = params[:user_id]
|
||||
end
|
||||
|
||||
def role_update
|
||||
user = User.find(params[:id])
|
||||
member_profile = user.member_profile
|
||||
if member_profile.update_attributes(params[:user])
|
||||
if member_profile.update_attributes(basic_info_params)
|
||||
redirect_to "/users/sign_in"
|
||||
else
|
||||
@roles = []
|
||||
# @roles = Role.where(:disabled => false)
|
||||
@roles = Role.where(:disabled => false)
|
||||
render :action => "role_page"
|
||||
end
|
||||
end
|
||||
|
@ -81,6 +85,12 @@ class UsersController < ApplicationController
|
|||
|
||||
private
|
||||
|
||||
def email_template(token)
|
||||
html = "<p>Thank you for registering your site with Orbit! Please click on the following link and confirm. This is to make sure we could provide you with a spam free experience. Thanks a lot.</p>"
|
||||
html = html + "<a href='#{confirm_user_users_url(:token => token)} /> Please click here </a>"
|
||||
html
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def user_params
|
||||
params.require(:user).permit(:password, :password_confirmation, :user_name, :member_profile_id, :email, :first_name, :last_name)
|
||||
|
|
|
@ -4,10 +4,10 @@ class Email
|
|||
|
||||
field :module_app_key
|
||||
field :mail_from
|
||||
field :mail_to
|
||||
field :mail_to #not optional
|
||||
field :mail_reply_to
|
||||
field :mail_subject
|
||||
field :mail_content
|
||||
field :mail_subject #not optional
|
||||
field :mail_content #not optional
|
||||
field :mail_sentdate , :type => DateTime, :default => Time.now
|
||||
field :mail_lang, :default => I18n.locale
|
||||
|
||||
|
|
|
@ -33,11 +33,6 @@ class User
|
|||
self.save
|
||||
end
|
||||
|
||||
def send_confirmation_email
|
||||
self.generate_confirmation_token
|
||||
ConfirmUserMailer.user_confirmation_email(self).deliver
|
||||
end
|
||||
|
||||
def self.confirm_email(confirmation_token = nil)
|
||||
if confirmation_token
|
||||
user = self.find_by(confirmation_token: confirmation_token) rescue nil
|
||||
|
|
|
@ -1,4 +1,2 @@
|
|||
<p>Thank you for registering your site with Orbit! Please click on the following link and confirm. This is to make sure we could provide you with a spam free experience. Thanks a lot.</p>
|
||||
|
||||
|
||||
<%= link_to 'Click here to confirm', confirm_user_users_url(:token => @confirmation_token)%>
|
||||
<a href="<%= @data['url'] %>" > Please click to confirm </a>
|
|
@ -9,7 +9,7 @@
|
|||
<span>OR</span>
|
||||
<div class="line right"></div>
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="facebook"><img src="assets/facebook-logo.png" /></a>
|
||||
<a href="javascript:void(0);" class="facebook"><img src="/assets/facebook-logo.png" /></a>
|
||||
</div>
|
||||
<div class="option-block msg alert hide"><h4></h4><br /><a href="<%= users_role_page_path(:user_id => @user.id.to_s) %>" class="btn btn-primary hide">Next</a></div>
|
||||
</div>
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<section id="main-wrap">
|
||||
<div class="sign-up have-other-sign-in">
|
||||
|
||||
<% flash.each do |key, msg| %>
|
||||
<%= content_tag :p, msg, :class => [key, "alert alert-error in fade"] %>
|
||||
<% end %>
|
||||
|
||||
<div class="form">
|
||||
<h3 class="login-logo">Sign up with Orbit</h3>
|
||||
<div class="form-block option-block">
|
||||
|
@ -25,20 +20,16 @@
|
|||
<div class="control-group clear">
|
||||
<label class="control-label" for="user_email"><%= t("user.first_name")%></label>
|
||||
<div class="controls">
|
||||
<%= text_field_tag :first_name, "", class: "availibility", id: "user_first_name", placeholder: t("users.first_name") %>
|
||||
<%= text_field_tag :first_name, "", id: "user_first_name", placeholder: t("users.first_name") %>
|
||||
<span class="loader hide"><img src="/assets/availability-check-loader.gif" /></span>
|
||||
<span class="notify not-ok hide alert alert-danger"><i class="icon-remove"></i>Not Available</span>
|
||||
<span class="notify ok hide alert alert-success"><i class="icon-ok"></i>Available</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group clear">
|
||||
<label class="control-label" for="user_email"><%= t("user.last_name")%></label>
|
||||
<div class="controls">
|
||||
<%= text_field_tag :last_name, "", class: "availibility", id: "user_last_name", placeholder: t("users.last_name") %>
|
||||
<%= text_field_tag :last_name, "", id: "user_last_name", placeholder: t("users.last_name") %>
|
||||
<span class="loader hide"><img src="/assets/availability-check-loader.gif" /></span>
|
||||
<span class="notify not-ok hide alert alert-danger"><i class="icon-remove"></i>Not Available</span>
|
||||
<span class="notify ok hide alert alert-success"><i class="icon-ok"></i>Available</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -76,4 +67,81 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function(){
|
||||
var validated = false;
|
||||
|
||||
$("form.content").submit(function(event) {
|
||||
var form = $(this);
|
||||
form.find("input").removeClass('error');
|
||||
form.find("input[type=text], input[type=email], input[type=password]").each(function(){
|
||||
validated = $(this).val() ? true : false;
|
||||
if(!validated){
|
||||
return false;
|
||||
}
|
||||
})
|
||||
if(validated){
|
||||
form.find("span.not-ok").each(function(){
|
||||
validated = $(this).hasClass('hide') ? true : false;
|
||||
if(!validated)return false;
|
||||
})
|
||||
}
|
||||
if(validated){
|
||||
validated = form.find("input[type=password]:eq(0)").val() == form.find("input[type=password]:eq(1)").val() ? true : false;
|
||||
if(!validated){
|
||||
form.find("input[type=password]").addClass('error');
|
||||
}
|
||||
}
|
||||
if(!validated){
|
||||
return false;;
|
||||
}
|
||||
});
|
||||
|
||||
$(".availibility").blur(function(){
|
||||
var type = $(this).attr("id"),
|
||||
loader = $(this).parent().find('.loader'),
|
||||
elem = $(this),
|
||||
value = $(this).val() || null;
|
||||
|
||||
elem.parent().find("span").addClass('hide');
|
||||
|
||||
var checkAvailability = function(){
|
||||
loader.removeClass('hide');
|
||||
elem.removeClass('error');
|
||||
$.ajax({
|
||||
url : "<%= users_check_availability_path %>",
|
||||
data : {"type" : type, "value" : value},
|
||||
dataType : "json",
|
||||
type : "get",
|
||||
success : function(data){
|
||||
loader.addClass('hide');
|
||||
if( data.success == true ){
|
||||
elem.parent().find(".ok").removeClass('hide');
|
||||
}else{
|
||||
elem.parent().find(".not-ok").removeClass('hide');
|
||||
elem.addClass('error');
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if( value ){
|
||||
if(type == "user_email" && validateEmail(value)){
|
||||
checkAvailability();
|
||||
}else if(type == "user_id"){
|
||||
checkAvailability();
|
||||
}else{
|
||||
elem.addClass('error');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
var validateEmail = function(email) {
|
||||
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA -Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
return re.test(email);
|
||||
}
|
||||
})();
|
||||
</script>
|
|
@ -13,7 +13,7 @@
|
|||
<%= role.title %>
|
||||
</label>
|
||||
<% end %>
|
||||
<input type="hidden" name="id" value="<%= @user_id %>"
|
||||
<input type="hidden" name="id" value="<%= @user_id %>" />
|
||||
</div>
|
||||
<h3 class="line"></h3>
|
||||
<input type="submit" value="Finish" class="btn btn-primary pull-right" />
|
||||
|
|
|
@ -59,10 +59,10 @@ Orbit::Application.routes.draw do
|
|||
|
||||
# Facebook routes
|
||||
|
||||
post "/facebook/register_fb" => "facebook#register_fb"
|
||||
get "/facebook/register_fb" => "facebook#register_fb"
|
||||
get "/facebook/get_friends" => "facebook#get_friends"
|
||||
get "/facebook/get_feed" => "facebook#get_feed"
|
||||
post "/facebook/disconnect" => "facebook#disconnect"
|
||||
get "/facebook/disconnect" => "facebook#disconnect"
|
||||
get "/facebook/server" => "facebook#server_redirect"
|
||||
get "/facebook/profile_import" => "facebook#profile_import"
|
||||
|
||||
|
|
Loading…
Reference in New Issue