Giter Club home page Giter Club logo

Comments (3)

jjtykkyl avatar jjtykkyl commented on July 24, 2024

There are a few ways to recognize the current user. As you initialize the library you should provide the "profilePictureURL" which is used to show the comments created by the current user AND it's shown on the lefthand side before the new comment placeholder as it indicates who is going to publish the new comment.

The comment objects contain also the "profilePictureURL" field and it's pre-filled from the field mentioned above (:591). However, when the comment is saved to the backend the profilePictureURL may be overridden by the server. Same goes for the author name: the name is set to "You" by default (:590) but may be overridden by the server.

In addition, the comment objects contain a field called "createdByCurrentUser" which can be used to determine whether the comment is created by the current user or not. jquery-comments is using this information to add certain class to the html element and enable editing for instance.

from jquery-comments.

webbird avatar webbird commented on July 24, 2024

I have seen that options, but I'm not sure how this should be used in production. I have created this solution now (for use with a CMS):

  • If the user is logged in, the "youText" is filled with his name. (I am doing this by adding a data-username attribute to the comments div, but this is quite unsecure)
  • If the user is NOT logged in (guest user), a name field is added to the form.

If comments are open for guest users, it would be nice to let them enter a name, instead of calling all of them "You" or "Guest" or something. ;)

from jquery-comments.

jessenieminen avatar jessenieminen commented on July 24, 2024

Thanks for the inquiry @webbird ! As @jjtykkyl already wrote, it's the responsibility of the backend to identify the user who makes the POST request for creating a new comment and then add the reference to that user's specific information.

Doing it in the backend ensures that a user can't fake comments from others and thus this isn't something that jquery-comments should have any further built in functionality for.

We added the special handling for changing the current user's name to 'You' so that it would be easier to distinguish themselves for the user and if you want to revert that and fall back to the real name of the user, feel free to do that just like you have, but it's not something we're planning to change.

Furthermore, jquery-comments is designed to be used in web applications, where it's encouraged to identify people's identities, e.g. having them be logged in. As you mentioned, the library also supports guest comments for those cases where it's necessary to give people the possibility to comment without being logged in but we have no plans to add support for anonymous commenting with a user entered name. So your current implementation of adding a name field to the form sounds like a reasonable workaround as long as you make sure your backend clearly distinguishes between guest users with a name and 'real' logged in users.

from jquery-comments.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.