Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8335829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:47:32+00:00 2026-06-09T03:47:32+00:00

I’m a little unsure about how to set up functionality for a login/logout control

  • 0

I’m a little unsure about how to set up functionality for a login/logout control in Backbone.js.

This is what I’m thinking, but I’m not sure if this is ok or if there are problems with this architecture:

  • The Model is the current user. If the model gets an HTTP 404 response when doing a fetch(), then the “current user” should be an anonymous user. If not, then the Model holds the current user’s information.
  • The View:
    • If the current user is “anonymous”, it shows input boxes for a user name and password; and a “login” button.
    • If the current user is a valid user, the view shows the current user’s username and a “logout” button.

I’m not sure what to do with the model when the “login” and “logout” buttons are pressed. Should the logging in and logging out be done through the model’s fetch() functionality, or should those actions trigger a different POST request whose successeful result either populates the Model or asks the Model to do another fetch()?

Any input is appreciated, thanks so much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:47:34+00:00Added an answer on June 9, 2026 at 3:47 am

    This may be a bit unexpected to what you’ve asked but this is how I’ve pulled it off:

    I’m not sure why do you need the model per se and I’m confused about how you are using it. Thus I’m not able to frame my answer with the “model” in mind.

    So here’s how I did it:

    In the view: just textboxes for login/logout.

    On clicking “login” send a POST request to the server with username/password (hopefully not in clear text 🙂

    If the server’s response is 200 change window.location to the target page you wish to see else display “invalid username/password” (of course the “next” page or any other page in the application should check to see if the user is logged in. If not, show login page).

    This is the simplest solution IMHO. I’m not sure why you need to have the model for the user? Is that “after” logging in? Then you can just generate and keep it or have it sent as part of the 200 response above. But the model won’t be persisted across the page change. Better to recreate the model on the ‘next’ page so to speak.

    (I’m assuming a page change and NOT a page load as in $.load – if the latter, then you can always reuse the model).

    Hope this makes sense. If not, could you please clarify the intent of the model and maybe I’ll be able to update my answer accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.