[WIP] Make new authentication request more flexible and with Ajax request support

- [ ] Add specs
elsif/else in one nesting?