I want to display a new flash msg on logout under a particular condition.. I'm overriding the after_sign_out_path_for method in application_controller.rb. I have added a new msg in devise.en.yml too. How do I flash the new msg on logout when its redirected to sign in page???
application_controller.rb:
def after_sign_out_path_for(resource_or_scope)
if is_already_logged_in?
flash.keep[:notice] = t("devise.failure.concurrent")// IS NOT WORKING
new_user_session_path
else
new_user_session_path(resource)
end
end
devise.en.yml:
en:
devise:
confirmations:
confirmed: "Your account was successfully confirmed. You are now signed in."
send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
failure:
already_authenticated: "You are already signed in."
inactive: "Your account was not activated yet."
invalid: "Invalid email or password."
invalid_token: "Invalid authentication token."
locked: "Your account is locked."
not_found_in_database: "Invalid email or password."
timeout: "Your session expired, please sign in again to continue."
unauthenticated: "You need to sign in or sign up before continuing."
unconfirmed: "You have to confirm your account before continuing."
// NEW MESSAGE ADDED
concurrent: "You are signed out due to concurrent sessions!"
mailer:
confirmation_instructions:
subject: "Confirmation instructions"
Related
I have a meteor app that seems to force a logout after 24 hours.
Our app (in beta) is using a "guest login" process where we create accounts on the fly, so i want to actually have an indefinite token lifetime.
Is there a way to extend the lifetime of these tokens?
Error logging in with token: Error: You've been logged out by the server. Please log in again. [403]
update failed: Access denied
Our guest login looks something like this:
postCreateUser = (username, password) ->
dclib.clog("login", "created", username)
Meteor.loginWithPassword username, password, ->
# FIXME? could this be in onCreateUser server side?
Meteor.call "createPersonalRoomIfNone"
if Meteor.isClient
Meteor.startup ->
unless Meteor.userId()
Meteor.call "getLastUserIndex", (err,index)->
if err
throw err
console.log("creating guest user", index)
username = "Guest #{index}"
password = Random.id()
Accounts.createUser
username: username
email: ""
password: password
role: "guest"
, -> postCreateUser(username, password)
this does it i hope!
# prevent users getting logged out
# http://devdocs.io/meteor/index#accounts_config
Accounts.config ({loginExpirationInDays: null})
I have this message when users register on my site, this is an excerpt of what is sent to the user and the email header message was incomplete. Take a look at what is sent when a user register
Email Subject = "[WWW Sites] Activate \http://1/"
And the email body message reads as below
"Thanks for registering! To complete the activation of your account and blog, please click the following link:
http://www.com/activate/?key=8b9c059db8ae9a5b
After you activate, you can visit your blog here:
\http://1/
So it is this incomplete messages that I would want to edit.
Thanks for your anticipated response
You have go through the filter method used in Wordpress Because you can not changed the email text or subject directly from the file because the email are comming from Buddypress core file so you can use the filter method.
Please put below code in your theme functions.php file.
1.) Change the subject for Activation email put below code:
function change_activation_subject($subject) {
return __( "Change Activate Your Account Subject", 'buddypress' );
}
add_filter('bp_core_activation_signup_user_notification_subject', 'change_activation_subject');
2.) Change the email body for Activation email put below code:
function change_activation_email_body($message) {
return __( "Change Activate Email body", 'buddypress' );
}
add_filter('bp_core_activation_signup_user_notification_subject', 'change_activation_email_body');
You get this error from phpmailer.
"Password not accepted from server: 535 Incorrect authentication data"
What causes this?
You must make sure that the Username given for the log-on is the same as the SetFrom email address.
This will return an error:
$mail->Username = "myemailaddress#gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->SetFrom('mysetfromaddress#gmail.com', 'Pagelinks');
This should not.
$mail->Username = "mysetfromaddress#gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->SetFrom('mysetfromaddress#gmail.com', 'Pagelinks');
When the Username and SetFrom do not match the authentication fails (according to an article found on Google).
I was trying to send email through Appcelerator Cloud Service, in my Titanium app. The code I'm using is the standart one, given at the documentation site. But the email is not being sent.
Cloud.Emails.send({
template: 'welcome',
recipients: '*******#gmail.com'
},
function (e) {
if (e.success) {
Titanium.API.info('Email sent successfully.');
} else {
Titanium.API.info('Error:\\n' +
((e.error && e.message) || JSON.stringify(e)));
}
});
It give the this error, 'Email template welcome is not found'. I was thinking that template is the message to be sent in email. There is no help on API about this attribute , template. Can anybody explain it to me? I'll be thankful.
Thanx
The error shows that you haven't created an email template on the ACS website yet. The following steps will help you to create email template
Log in to your Appcelerator App Console
click "Manage ACS" under the app you're working on
click the "Email Templates" tab
"Create an Email Template".
also you can setup your SMTP settings as follows which worked for me.
Username: ________#gmail.com
Password: gmail account password
TLS: true/ false (both will work)
SMTP Address: smtp.gmail.com
Port: 587
Domain : www.gmail.com
That error means you haven't created an email template on the ACS website yet. Log in to your Appcelerator App Console, click "Manage ACS" under the app you're working on, then click the "Email Templates" tab, and "Create an Email Template".
i am working on rails3 application. In my application when a user registered first time, an email has been sent to user with a verification link, after clicking that link i update the status_id and redirect user to login page. Here is my code :
code for token generation:
require 'digest/sha2'
class Subscription < ActiveRecord::Base
validate :ids_must_be_present, :on => :create
def ids_must_be_present
if status_id==0
generate_token
else
errors.add('Something gone wrong')
end
end
def generate_token
self.token = encrypt_string(id, generate_salt)
end
def encrypt_string(id, salt)
Digest::SHA2.hexdigest(id.to_s + "prftnxt" + salt)
end
private
def generate_salt
self.object_id.to_s + rand.to_s + company_id.to_s + Time.now.to_i.to_s
end
end
code to send email with link:
def email_verify
if subscription = Subscription.find_by_id_and_token(params[:id], params[:token])
subscription.update_attribute(:status_id, 1)
redirect_to("/login/index", :notice => "Thanks, email successfully verified")
else
flash.now[:notice] = "Your email has not verified yet. Please verify your email by clicking the link we have sent you."
end
end
Email template with verification link:
Hello <b><%= #user.username %></b>,
<br/>
<br/>
Thank you for signing up .
<b> Please Verify your email</b>
<%= link_to "verify", "http://localhost:3000/login/email_verify?token=#{#subscription.token}&id=#{#subscription.id}"%>
</br></br>
</br>
Now everything is fine, now my client want if user did not get verification email, then we some where give the option or link to request to resend verification mail.
i am thinking on to display flash msg on login attempt with a link to request for email.
but i am confused how do i do this any example or help would be helpful thanks.
Hi friends i got a solution, i have used a method in login controller that check the email is verified or not and if not verified a flash message displayed. The message contains the link .
When a user click on that link i resend the verification mail.
Here is my code:
subscription = Subscription.find_by_company_id_and_plan_id(current_company.id, current_company.plan.id)
link = "<a href= '/login/resend_verification_email'>Click</a>"
if subscription.status_id == 0
flash[:error] = "Your email is not verified. Please verify before login. <br/> #{link} here to resend verification email.".html_safe
redirect_to :back
end
and in login controller:
def resend_verification_email
subscription = Subscription.find_by_company_id_and_plan_id(current_company.id, current_company.plan.id)
Email.verify_email(current_user, subscription).deliver
redirect_to :back
flash[:success] = 'Verification email has been resend successfully, please check your inbox.'
end