func (p *politeiawww) handleLogin(w http.ResponseWriter, r *http.Request) {
	log.Tracef("handleLogin")

	// Get the login command.
	var l v1.Login
	decoder := json.NewDecoder(r.Body)
	if err := decoder.Decode(&l); err != nil {
		RespondWithError(w, r, 0, "handleLogin: failed to decode: %v", err)
		return
	}

	reply, err := p.backend.ProcessLogin(l)
	if err != nil {
		RespondWithError(w, r, http.StatusUnauthorized,
			"handleLogin: ProcessLogin %v", err)
		return
	}

	// Mark user as logged in if there's no error.
	err = p.setSessionUser(w, r, l.Email)
	if err != nil {
		RespondWithError(w, r, 0,
			"handleLogin: setSessionUser %v", err)
		return
	}

	// Reply with the user information.
	util.RespondWithJSON(w, http.StatusOK, reply)
}
// handleLogin handles the incoming login command.  It verifies that the user
// exists and the accompanying password.  On success a cookie is added to the
// gorilla sessions that must be returned on subsequent calls.
handleLogin handles the incoming login command.  It verifies that the user
exists and the accompanying password.  On success a cookie is added to the
gorilla sessions that must be returned on subsequent calls.
// handleLogin handles the incoming login command . It verifies that the user // exists and the accompanying password . On success a cookie is added to the // gorilla sessions that must be returned on subsequent calls .
func (p *politeiawww) handleLogin(w http.ResponseWriter, r *http.Request) {
	log.Tracef("handleLogin")
	var l v1.Login
	decoder := json.NewDecoder(r.Body)
	if err := decoder.Decode(&l); err != nil {
		RespondWithError(w, r, 0, "handleLogin: failed to decode: %v", err)
		return
	}
	reply, err := p.backend.ProcessLogin(l)
	if err != nil {
		RespondWithError(w, r, http.StatusUnauthorized,
			"handleLogin: ProcessLogin %v", err)
		return
	}
	err = p.setSessionUser(w, r, l.Email)
	if err != nil {
		RespondWithError(w, r, 0,
			"handleLogin: setSessionUser %v", err)
		return
	}
	util.RespondWithJSON(w, http.StatusOK, reply)
}
func ( p * politeiawww ) handleLogin ( w http . ResponseWriter , r * http . Request ) { log . Tracef ( " " ) var l v1 . Login decoder := json . NewDecoder ( r . Body ) if err := decoder . Decode ( & l ) ; err != nil { RespondWithError ( w , r , 0 , " " , err ) return } reply , err := p . backend . ProcessLogin ( l ) if err != nil { RespondWithError ( w , r , http . StatusUnauthorized , " " , err ) return } err = p . setSessionUser ( w , r , l . Email ) if err != nil { RespondWithError ( w , r , 0 , " " , err ) return } util . RespondWithJSON ( w , http . StatusOK , reply ) }
handleLogin handles the incoming login command.
handleLogin handles the incoming login command .
// Get the login command. // Mark user as logged in if there's no error. // Reply with the user information.