Giter VIP home page Giter VIP logo

go-gin-app's People

Contributors

andygrunwald avatar kulshekhar avatar tomfern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-gin-app's Issues

undefined: showIndexPage

Just create routes.go

call from main.go

go build -o app

it's show messages:
./routes.go:6:18: undefined: showIndexPage

bypass auth by setting token

request : curl -v --cookie "token=everything_not_empty" localhost:8080
response :

<nav class="navbar navbar-default">
  <div class="container">
    <div class="navbar-header">
      <a class="navbar-brand" href="/">
        Home
      </a>
    </div>
    <ul class="nav navbar-nav">       
        <li><a href="/article/create">Create Article</a></li>
        <li><a href="/u/logout">Logout</a></li>
    </ul>
  </div>
</nav>
...

when the cookie token is set, you are seen as an authenticated user even if you are not logged in

this is because of the setUserStatus function

func setUserStatus() gin.HandlerFunc {
	return func(c *gin.Context) {
		if token, err := c.Cookie("token"); err == nil || token != "" {
			c.Set("is_logged_in", true)
		} else {
			c.Set("is_logged_in", false)
		}
	}
}

i think a solution could be if tocken, err := c.Cookie("token"); err == nil || isTokenValide(token)
where isTokenValide whould check against a database if the token has been issued

missing backticks

The article that goes with this has a typo. When models.article.go is first defined the article struct is missing the backticks:

type article struct {
  ID      int    json:"id"
  Title   string json:"title"
  Content string json:"content"
}

error of too many arguments

hi
when I run the code it shows
"./handlers.user.go:31:14: too many arguments in call to c.SetCookie
have (string, string, number, string, string, http.SameSite, bool, bool)
want (string, string, int, string, string, bool, bool)
./handlers.user.go:58:13: too many arguments in call to c.SetCookie
have (string, string, number, string, string, http.SameSite, bool, bool)
want (string, string, int, string, string, bool, bool)
./handlers.user.go:80:14: too many arguments in call to c.SetCookie
have (string, string, number, string, string, http.SameSite, bool, bool)
want (string, string, int, string, string, bool, bool)"

could you help sove it ?

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.