Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am building a website for a class the following is my code for google sign in. The follwoing code is for the index page
I am building a website for a class the following is my code for google sign in.
The follwoing code is for the index page where the user first visits. Once they login with google they are redirected to the homepage.
How can I make it so the homepage is not accesible to anybody that is not signed in. Currently if i type the url in the web browser i still have access to the home page. What code can I add to the home page??
Home page
K?php class GoogleAuth protected $db; protected $client; public function construct(DB $db null, Google Client $googleClient null) $this->db $db; $this- client $googleClient. ($this->client $this- client->setclientid('361982001136-ghjdqd7kb74h1vaii.apps.googleusercontent.com'); $this- client- setclientsecret('7Pgq6b164GR7y'); $this- client->setRedirectUni('https://the-coyote-xchange-emmanuelgi13546904.codeanyapp.com/index.php'); $this- client->se tScopes( email') public function isLoggedIn() return isset SESSION 'access token'D public function getAuthurl() return $this->client- createAuthurl public function checkRedirectCode() if(isset GETC' code'])) $this- client- authenticate($ GETC'code' J); $this- set Token ($this client->getAccessToken()) $this-> storeUser($this->getPayload()) return true; return false
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started