Fixed a bit of logic in the model

Trying to handle 302 (SSL redirect) in javascript