Enter email address and phone number before accessing survey - joomla

I am new in joomla 1.5 .
I am trying to implement a survey form. If the user is not a registered user then he or she can access the survey form after providing his or her email address and phone number. Else if the user is a registered user then he/she can get the access the survey form directly, no need to provide the email or phone number. Then according to that survey admin can interact with him / her through that email id or phone number.
How shall I progress according to this scenario.

//detect if a user entity exists in the session:
$user = JFactory::getUser();
if ($user->guest) { //this is a registered user
//redirect to the survey page
header('Location: http://www.example.com/your-survey');
}
else{
//display a form
//with email & phone number
}

Related

User's email update time Send an email for authentication in laravel

When the user registers, an email will be sent to confirmation
But how do I send a notification when a user updates their email?
Like when he registers
if you want to reverify your user's email , you should set his email_verified_at to null then call sendEmailVerificationNotification method .
in your user model (located in app\user) add this method :
public function sendNewVerification() {
$this->email_verified_at =null;
$this->sendEmailVerificationNotification();
}
and call it in your controller .
hope that would work.

Laravel Email Greeting show Name instead of ID

Hello I wanted to ask regarding the Email Notification on Laravel, I have made a Status Notification wher I added this code
public function toMail($notifiable)
{
$leaveStatus=$this->leave->status;
if($leaveStatus==1){
$leaveNotify=" approved ";
}
else{
$leaveNotify=" declined ";
}
return (new MailMessage)
->subject('Leave Status')
->greeting('Hello '.$this->leave->user_id)
->line('I hope you are doing well')
->line('Your requested leave of' . $this->leave->type. ' type has been ' .$leaveNotify)
->line('Leave type: ' .$this->leave->type)
->line('From dt :' .$this->leave->from)
->line('To dt :' .$this->leave->to);
}
This works very well the email is being sent in each change on a Leave Application so what I am looking for is the part of the greeting , the
greeting('Hello '.$this->leave->user_id)
It shows the ID of the user instead of the first_name(which is a filed for the name) I have tried adding a ->first_name after the user_id but then it returns an error, the user_id doesn't have a foreign key that connects it with the users table its just a field which stores the id of each authenticated users but it works all the way here so im not sure that is the problem
You can use the notifiable variable passed into the function, which is the user the email is being sent to.
->greeting('Hello '.$notifiable->first_name)
You need to add relation for user in that model. See https://laravel.com/docs/7.x/eloquent-relationships . After that call it via $this->leave->user->first_name

Codeigniter ION auth unique group login form

I am new in ION-Auth, I want to make admin panel unique login form where admin can only login (no other user groups can allows to login here) and one for unique login form for employee group where employee can login only.
Let's say Group A is the Admin.
In the Group A controller, allow everyone to login first so you are able to check in what group that user belonged to.
Right after logging in, check if the user is an admin so he can access the Group A panel. You can check if the current user is admin by call thie is_admin metho
if($this->ion_auth->login($email, $password, $remember))
{
// It means the user has logged in. He has the correct user/pass
// Check if he is an admin
if(!$this->ion_auth->is_admin())
{ // Log out if not
$this->ion_auth->logout();
}
else
{
// Allow the access to the Group A pages
}
}
else
{
// Show the form again
}

Codeigniter securing certain pages based on user account

I am developing a system whereby a user is a member of a Client account. There are 5 or 6 clients, and each client has a number of users. When a user logs in, the site is styled to the client they are a member of.
I have a function "view_campaign":
function view_campaign($campaignID = FALSE){
$this->load->model('client_model');
$this->load->model('campaign_model');
$data['main_content'] = 'campaign_overview';
$this->load->view('includes/template', $data);
}
So in the URL for example we have .../campaign/view_campaign/21 (for example). This will mean that the user gets to their campaign which has an ID of 21.
But how can I make it so it's secure i.e. users that are members of another client cant view the campaign? They could just change the URL and view campaigns related to other clients...
Thanks
Quite a broad question, I'm not sure what your database structure is but you want to do something like...
When the user first logs in you want to save their user ID and their client ID in a session. Then you want to have a function in your campaign model that gets the client ID a campaign belongs to.
Your view_campaign function would look something like
function view_campaign($campaignID = FALSE) {
$this->load->model('client_model');
$this->load->model('campaign_model');
//Get the user ID and client ID from a session or something
$userId = $this->session->userdata('userId');
$clientId = $this->session->userdata('clientId');
//Call a function in your model to see if the user belongs to the client
$campaignClientId = $this->campaign_model->getClient($campaignID )
//If the client ID the campaign belongs to matches the client ID the user
//belongs to then they can view it
if($campaignClientId === $clientId ) {
$data['main_content'] = 'campaign_overview';
$this->load->view('includes/template', $data);
} else {
//Redirect to another page
}
}

CakePHP 2.0 Automatic Login after Account Activation

I'm just working on the user management-component of our new project.
The plan is:
User registers on the page with minimal amount of account data (username, pass, email)
User gets an email with an activation link to activate the account
User clicks on the link and activates his account
The system logs in the user after automatically after activation and redirects him to kind of a dashboard with account information (last login, hi "username", etc.)
But there are some problems with the auto login. this is the part of the code i use:
<?php
...
// set userstatus to "active" and delete meta information "activation_key"
// then automatically login
$this->User->id = $id;
$this->User->saveField('modified', date('Y-m-d H:i:s') );
$this->User->saveField('status', 1 );
// $this->User->deleteActivationKey ....
$this->Auth->login($this->User->read());
$this->Session->setFlash(__('Successfully activated account. You are now logged in.'));
$this->User->saveField('last_login', date('Y-m-d H:i:s') );
$this->redirect(array('controller' => 'pages'));
...
This works so far, until you want to get information about the logged in user with the user() function of the Auth Component.
We're using this in AppController->beforeRender, to have user information application wide:
$this->set('auth', $this->Auth->user());
but after that auto login action, i'm getting undefined index notices. (e.g. by accessing $auth['id'] in a view). print_r() shows me only the username and hashed password of the current user.
If you login manually, everything works fine. it must be something with the automatic login after the account activation.
Seems to be a problem with the session? What am i doing wrong?
Found a solution after testing many variations.
Works now with:
$user = $this->User->findById($id);
$user = $user['User'];
$this->Auth->login($user);
Don't know why, i thought i tried this way already and that did not work.
Have you tried this? (CakePHP 2.x)
public function signup() {
if (!empty($this->request->data)) {
// Registration stuff
// Auto login
if ($this->Auth->login()) {
$this->redirect('/');
}
}
}
That simple!

Resources