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)
|
data = JSON.parse(friends)
|
||||||
if data["success"]
|
if data["success"]
|
||||||
user = JSON.parse(data["user"])
|
user = JSON.parse(data["user"])
|
||||||
u = User.find(temp_user.id)
|
u = User.find(temp_user.id).member_profile
|
||||||
firstname = {}
|
# firstname = {}
|
||||||
lastname = {}
|
# lastname = {}
|
||||||
@site_valid_locales.each do |locale|
|
# @site_valid_locales.each do |locale|
|
||||||
firstname[locale] = user["first_name"]
|
# firstname[locale] = user["first_name"]
|
||||||
lastname[locale] = user["last_name"]
|
# lastname[locale] = user["last_name"]
|
||||||
end
|
# end
|
||||||
u.first_name_translations = firstname
|
# u.first_name_translations = firstname
|
||||||
u.last_name_translations = lastname
|
# u.last_name_translations = lastname
|
||||||
u.office_tel = user["phone"]
|
u.office_tel = user["phone"]
|
||||||
u.sex = user["gender"] || "unknown"
|
u.sex = user["gender"] || "unknown"
|
||||||
u.remote_avatar_url = user["picture"] if user["picture"]
|
u.remote_avatar_url = user["picture"] if user["picture"]
|
||||||
|
@ -111,7 +111,7 @@ class FacebookController < ApplicationController
|
||||||
if !@url.nil?
|
if !@url.nil?
|
||||||
redirect_to @url
|
redirect_to @url
|
||||||
else
|
else
|
||||||
render :layout=> "devise"
|
render :layout=> "authentication"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -10,17 +10,23 @@ class UsersController < ApplicationController
|
||||||
if @user.save
|
if @user.save
|
||||||
@member.save
|
@member.save
|
||||||
@user.update_attributes(member_profile_id: @member.id)
|
@user.update_attributes(member_profile_id: @member.id)
|
||||||
redirect_to root_url, :notice => "Signed Up Successfully, Please Check your email for confirmation!"
|
redirect_to users_confirmation_path
|
||||||
@user.send_confirmation_email
|
@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
|
else
|
||||||
render "new"
|
render "new"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def confirmation
|
||||||
|
end
|
||||||
|
|
||||||
def confirm_user
|
def confirm_user
|
||||||
user = User.confirm_email(params[:token])
|
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")
|
if user[:success].eql?("true")
|
||||||
flash[:notice] = "You have confirmed successfully"
|
flash[:notice] = "You have confirmed successfully"
|
||||||
else
|
else
|
||||||
|
@ -51,19 +57,17 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def role_page
|
def role_page
|
||||||
@roles = []
|
@roles = Role.where(:disabled => false)
|
||||||
# @roles = Role.where(:disabled => false)
|
|
||||||
@user_id = params[:user_id]
|
@user_id = params[:user_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
def role_update
|
def role_update
|
||||||
user = User.find(params[:id])
|
user = User.find(params[:id])
|
||||||
member_profile = user.member_profile
|
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"
|
redirect_to "/users/sign_in"
|
||||||
else
|
else
|
||||||
@roles = []
|
@roles = Role.where(:disabled => false)
|
||||||
# @roles = Role.where(:disabled => false)
|
|
||||||
render :action => "role_page"
|
render :action => "role_page"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -81,6 +85,12 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
private
|
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.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def user_params
|
def user_params
|
||||||
params.require(:user).permit(:password, :password_confirmation, :user_name, :member_profile_id, :email, :first_name, :last_name)
|
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 :module_app_key
|
||||||
field :mail_from
|
field :mail_from
|
||||||
field :mail_to
|
field :mail_to #not optional
|
||||||
field :mail_reply_to
|
field :mail_reply_to
|
||||||
field :mail_subject
|
field :mail_subject #not optional
|
||||||
field :mail_content
|
field :mail_content #not optional
|
||||||
field :mail_sentdate , :type => DateTime, :default => Time.now
|
field :mail_sentdate , :type => DateTime, :default => Time.now
|
||||||
field :mail_lang, :default => I18n.locale
|
field :mail_lang, :default => I18n.locale
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,6 @@ class User
|
||||||
self.save
|
self.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_confirmation_email
|
|
||||||
self.generate_confirmation_token
|
|
||||||
ConfirmUserMailer.user_confirmation_email(self).deliver
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.confirm_email(confirmation_token = nil)
|
def self.confirm_email(confirmation_token = nil)
|
||||||
if confirmation_token
|
if confirmation_token
|
||||||
user = self.find_by(confirmation_token: confirmation_token) rescue nil
|
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>
|
<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>
|
||||||
|
<a href="<%= @data['url'] %>" > Please click to confirm </a>
|
||||||
|
|
||||||
<%= link_to 'Click here to confirm', confirm_user_users_url(:token => @confirmation_token)%>
|
|
|
@ -9,7 +9,7 @@
|
||||||
<span>OR</span>
|
<span>OR</span>
|
||||||
<div class="line right"></div>
|
<div class="line right"></div>
|
||||||
</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>
|
||||||
<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 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>
|
</div>
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
<section id="main-wrap">
|
<section id="main-wrap">
|
||||||
<div class="sign-up have-other-sign-in">
|
<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">
|
<div class="form">
|
||||||
<h3 class="login-logo">Sign up with Orbit</h3>
|
<h3 class="login-logo">Sign up with Orbit</h3>
|
||||||
<div class="form-block option-block">
|
<div class="form-block option-block">
|
||||||
|
@ -25,20 +20,16 @@
|
||||||
<div class="control-group clear">
|
<div class="control-group clear">
|
||||||
<label class="control-label" for="user_email"><%= t("user.first_name")%></label>
|
<label class="control-label" for="user_email"><%= t("user.first_name")%></label>
|
||||||
<div class="controls">
|
<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="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>
|
</div>
|
||||||
|
|
||||||
<div class="control-group clear">
|
<div class="control-group clear">
|
||||||
<label class="control-label" for="user_email"><%= t("user.last_name")%></label>
|
<label class="control-label" for="user_email"><%= t("user.last_name")%></label>
|
||||||
<div class="controls">
|
<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="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>
|
</div>
|
||||||
|
|
||||||
|
@ -76,4 +67,81 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</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 %>
|
<%= role.title %>
|
||||||
</label>
|
</label>
|
||||||
<% end %>
|
<% end %>
|
||||||
<input type="hidden" name="id" value="<%= @user_id %>"
|
<input type="hidden" name="id" value="<%= @user_id %>" />
|
||||||
</div>
|
</div>
|
||||||
<h3 class="line"></h3>
|
<h3 class="line"></h3>
|
||||||
<input type="submit" value="Finish" class="btn btn-primary pull-right" />
|
<input type="submit" value="Finish" class="btn btn-primary pull-right" />
|
||||||
|
|
|
@ -59,10 +59,10 @@ Orbit::Application.routes.draw do
|
||||||
|
|
||||||
# Facebook routes
|
# 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_friends" => "facebook#get_friends"
|
||||||
get "/facebook/get_feed" => "facebook#get_feed"
|
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/server" => "facebook#server_redirect"
|
||||||
get "/facebook/profile_import" => "facebook#profile_import"
|
get "/facebook/profile_import" => "facebook#profile_import"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue