Extracting data from Passport JS authentication request - Angular JS

Looking to extract the email attribute of the current user on my website. Here is a snippet of the code I am working with:

$scope.deleteit = function(data) {
        var deletepost = data;
        console.log(Auth.currentUser());
        // console.log(Auth.currentUser().email) //returns undefined
}

Here is the output reflected in my browser's developer console:

Resource { $promise={...}, $resolved=false, $get=function(), more...}

Upon clicking the above content within the dev console, this information is visible:

$promise

    Object { then=function(), catch=function(), finally=function()}

$resolved

    true

__v

    0

_id

    "53c3ef3f8766558e16233dd0"

email

    "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="28505050684f45494144064b4745">[email protected]</a>"

name

    "xxx"

provider

    "local"

role

    "user"

$delete

    function(params, success, error)

$get

    function(params, success, error)

$query

    function(params, success, error)

$remove

    function(params, success, error)

$save

    function(params, success, error)

$update

    function(params, success, error)

__proto__

    Resource { $get=function(), $save=function(), $query=function(), more...}

Any tips on how to access the email attribute?

Additionally, I am in the process of establishing a method to verify whether the post owner is the one attempting to delete it.

Answer №1

In order to complete the express route tasks, I developed a custom function to forward req.user.email as needed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Trapped in the dilemma of encountering the error message "Anticipated an assignment or function: no-unused expressions"

Currently facing a perplexing issue and seeking assistance from the community to resolve it. The problem arises from the code snippet within my model: this.text = json.text ? json.text : '' This triggers a warning in my inspector stating: Ex ...

Node.js: Manageable simultaneous looping operations

I manage a mongoDB collection containing 1.7 million records, each record representing an ID number. My task involves extracting each ID number, sending requests to another service, performing data transformations, saving the modified data to a separate co ...

Issue with AJAX not receiving successful response after function invocation

I am trying to dynamically load data based on the specific URI segment present on the page. Below is my JavaScript code: $(document).ready(function() { $(function() { load_custom_topics(); }); $('#topics_form').submit(funct ...

What is the best way to store and retrieve information in JSON format?

Looking to create a forum using Angular JS and in need of advice on creating JSON data files to store and retrieve information. One key requirement is the ability to add new data directly from the browser, without modifying the data file itself. Any help ...

Controller Undefined Angular Form Issue

Currently, I am facing an issue with my angular form that I am passing into my controller. Upon inspecting the form in the browser, I noticed that it is coming up as undefined. I have attempted to troubleshoot by changing the form's name and adjustin ...

Experience the click action that comes equipped with two unique functions: the ability to effortlessly add or remove a class

Currently, I am in the process of creating a list of anchor links that contain nested anchor links, and there are a few functionalities that I am looking to implement. Upon clicking on a link: Add a class of "current" Remove the class of "current" from ...

The consistent index is shared among all dynamically generated elements

I'm currently working on a project where I am generating dropdowns within a table dynamically. I am attempting to determine the index of the dropdown that triggered the event in the following way: $(".template").on('change', '.dataType ...

Discover the steps for integrating an object into a Ext.grid.Panel using Sencha Ext Js

Currently, I am utilizing Sencha Ext Js 4 and have integrated an Ext.grid.Panel into my project. I am interested in adding another element inside the header, such as a textbox. Is this achievable? {filterable: true, header: 'Unique' /*Here i w ...

Is it possible to incorporate an element using absolute positioning using jQuery or Javascript?

When trying to add a new element on the screen, I am facing an issue with the absolute positioning not working properly. Sample Code in Javascript function drawElement(e,name){ $("#canvas").append("<div id='" + name + "' class='e ...

Live Reload isn't functioning

I recently came across some videos where the app automatically recompiled whenever any changes in the code were made. Typically, when ng serve is run, it should display a message like: Live reload server on ... However, for some reason this feature do ...

executing concurrent npm tasks on a Windows operating system

After setting up an npm parallel script in my package.json, I noticed that it works smoothly on a mac but encounters issues when run on windows: "myScript": "nodemon ./server.js & cross-env NODE_ENV=development webpack-dev-server" However, when the s ...

How can we prevent the automatic redirection to the home page index.html?

The page you are trying to access contains data that you previously entered. Revisiting the page may result in repeating any actions you have taken. Do you wish to proceed? Upon refresh, this message appears and the form data is resubmitted to Flask. How ...

Angular's route resolve feature does not wait for the promise to resolve before

I just started using angular and I'm facing an issue with my user route. I'm trying to resolve the user object before rendering the view, but even after injecting $q and deferring the promise, the view is loading before the promise gets returned. ...

Executing Leaflet on the Node.js backend server

I have been attempting to run Leaflet on a Node.js server without success. I followed the instructions in the download section and used Jake to build it, but when I try to require Leaflet in a server file and start my node server, it crashes with the error ...

iPhone: Span clicking not functioning properly

When trying to access the second level of menu navigation by touching the arrow span, there seems to be an issue. When I tap on the arrow, it behaves as if I tapped on the page itself (e.g., Philosophie). The arrow has a CSS property of cursor:pointer; and ...

Validation errors are returned by express-validator duplicated

I am working on validating the request object using Express-Validator. Suppose I have two routes: a GET /users/:id route (fetchUserById) and a POST /users route (createUser). this.router = express.Router(); this.router.route('/').post(this.userR ...

Adding a new item to the table to include an error object in NodeJS

While experimenting with my Node.js and MongoDB setup, I encountered an issue where I was unable to update an object. const { MongoClient, ObjectID } = require('mongodb'); // or as an es module: // import { MongoClient } from 'mongodb' ...

Attempting to resolve the Bootstrap issue, currently in search of a suitable solution

Today I made the decision to utilize bootstrap to create a menu, but unfortunately, I've encountered a strange bug or conflict involving jQuery, potentially the UI, and Bootstrap. If you'd like, you can take a look at the picture provided in the ...

Rotating a non-centered triangle geometry in ThreeJS

I've been struggling to understand why my triangle isn't rotating around the center as I expected. My goal is to have two triangles side by side, with one rotated 60 degrees. However, when I rotate them, all corners should remain the same size. ...

Having trouble getting a Chrome extension/jQuery to work on certain sites but not others? Attempting to trigger an event when a link is clicked

For three different websites, I have three separate js files. I want to mention that the manifest has the correct settings to make sure these files work on the right sites, but unfortunately, only one function of the extension (the most important one) is n ...